Program: 146006
Project: 146006
Buggy source:
@Override public void validate(ValidationHandler handler){
  if (!superTypes.isEmpty()) {
    List<TypeMetadata> thisSuperTypes=new LinkedList<TypeMetadata>(superTypes);
    for (    TypeMetadata superType : thisSuperTypes) {
      if (isInstantiable() == superType.isInstantiable()) {
        if (superType instanceof ComplexTypeMetadata) {
          Collection<FieldMetadata> thisTypeKeyFields=getKeyFields();
          for (          FieldMetadata thisTypeKeyField : thisTypeKeyFields) {
            if (!((ComplexTypeMetadata)superType).hasField(thisTypeKeyField.getName())) {
              handler.error(superType,"String_Node_Str" + name + "String_Node_Str"+ "String_Node_Str"+ superType.getName()+ "String_Node_Str",superType.<Element>getData(MetadataRepository.XSD_DOM_ELEMENT),superType.<Integer>getData(MetadataRepository.XSD_LINE_NUMBER),superType.<Integer>getData(MetadataRepository.XSD_COLUMN_NUMBER),ValidationError.TYPE_CANNOT_OVERRIDE_SUPER_TYPE_KEY);
            }
          }
        }
      }
    }
  }
  for (  FieldMetadata value : fieldMetadata.values()) {
    value.validate(handler);
  }
  for (  FieldMetadata keyField : keyFields.values()) {
    keyField.validate(handler);
    FieldMetadata frozenField=keyField.freeze(handler);
    if (frozenField.isMany()) {
      handler.error(frozenField,"String_Node_Str",frozenField.<Element>getData(MetadataRepository.XSD_DOM_ELEMENT),frozenField.<Integer>getData(MetadataRepository.XSD_LINE_NUMBER),frozenField.<Integer>getData(MetadataRepository.XSD_COLUMN_NUMBER),ValidationError.FIELD_KEY_CANNOT_BE_REPEATABLE);
    }
    if (!frozenField.isMandatory()) {
      handler.error(frozenField,"String_Node_Str",frozenField.<Element>getData(MetadataRepository.XSD_DOM_ELEMENT),frozenField.<Integer>getData(MetadataRepository.XSD_LINE_NUMBER),frozenField.<Integer>getData(MetadataRepository.XSD_COLUMN_NUMBER),ValidationError.FIELD_KEY_MUST_BE_MANDATORY);
    }
  }
  for (  FieldMetadata pkInfo : primaryKeyInfo) {
    if (!this.equals(pkInfo.getContainingType())) {
      handler.error(this,"String_Node_Str",pkInfo.<Element>getData(MetadataRepository.XSD_DOM_ELEMENT),pkInfo.<Integer>getData(MetadataRepository.XSD_LINE_NUMBER),pkInfo.<Integer>getData(MetadataRepository.XSD_COLUMN_NUMBER),ValidationError.PRIMARY_KEY_INFO_NOT_IN_ENTITY);
      continue;
    }
    int previousErrorCount=handler.getErrorCount();
    pkInfo.validate(handler);
    if (handler.getErrorCount() == previousErrorCount) {
      if (pkInfo.isMany()) {
        handler.error(this,"String_Node_Str",pkInfo.<Element>getData(MetadataRepository.XSD_DOM_ELEMENT),pkInfo.<Integer>getData(MetadataRepository.XSD_LINE_NUMBER),pkInfo.<Integer>getData(MetadataRepository.XSD_COLUMN_NUMBER),ValidationError.PRIMARY_KEY_INFO_CANNOT_BE_REPEATABLE);
        continue;
      }
      if (!isPrimitiveTypeField(pkInfo)) {
        handler.warning(this,"String_Node_Str",pkInfo.<Element>getData(MetadataRepository.XSD_DOM_ELEMENT),pkInfo.<Integer>getData(MetadataRepository.XSD_LINE_NUMBER),pkInfo.<Integer>getData(MetadataRepository.XSD_COLUMN_NUMBER),ValidationError.PRIMARY_KEY_INFO_TYPE_NOT_PRIMITIVE);
      }
    }
  }
  for (  FieldMetadata lookupField : lookupFields) {
    int errorCount=handler.getErrorCount();
    lookupField.validate(handler);
    if (handler.getErrorCount() > errorCount) {
      continue;
    }
    if (!this.equals(lookupField.getContainingType())) {
      handler.error(this,"String_Node_Str",lookupField.<Element>getData(MetadataRepository.XSD_DOM_ELEMENT),lookupField.<Integer>getData(MetadataRepository.XSD_LINE_NUMBER),lookupField.<Integer>getData(MetadataRepository.XSD_COLUMN_NUMBER),ValidationError.LOOKUP_FIELD_NOT_IN_ENTITY);
      continue;
    }
    lookupField.getContainingType().freeze(handler);
    if (lookupField.isKey()) {
      handler.error(this,"String_Node_Str",lookupField.<Element>getData(MetadataRepository.XSD_DOM_ELEMENT),lookupField.<Integer>getData(MetadataRepository.XSD_LINE_NUMBER),lookupField.<Integer>getData(MetadataRepository.XSD_COLUMN_NUMBER),ValidationError.LOOKUP_FIELD_CANNOT_BE_KEY);
      continue;
    }
    lookupField.validate(handler);
    if (!isPrimitiveTypeField(lookupField)) {
      handler.error(this,"String_Node_Str",lookupField.<Element>getData(MetadataRepository.XSD_DOM_ELEMENT),lookupField.<Integer>getData(MetadataRepository.XSD_LINE_NUMBER),lookupField.<Integer>getData(MetadataRepository.XSD_COLUMN_NUMBER),ValidationError.LOOKUP_FIELD_MUST_BE_SIMPLE_TYPE);
    }
  }
}

Fixed version (ground truth):
@Override public void validate(ValidationHandler handler){
  if (isValidated) {
    return;
  }
  int originalErrorCount=handler.getErrorCount();
  if (!superTypes.isEmpty()) {
    List<TypeMetadata> thisSuperTypes=new LinkedList<TypeMetadata>(superTypes);
    for (    TypeMetadata superType : thisSuperTypes) {
      if (isInstantiable() == superType.isInstantiable()) {
        if (superType instanceof ComplexTypeMetadata) {
          Collection<FieldMetadata> thisTypeKeyFields=getKeyFields();
          for (          FieldMetadata thisTypeKeyField : thisTypeKeyFields) {
            if (!((ComplexTypeMetadata)superType).hasField(thisTypeKeyField.getName())) {
              handler.error(superType,"String_Node_Str" + name + "String_Node_Str"+ "String_Node_Str"+ superType.getName()+ "String_Node_Str",superType.<Element>getData(MetadataRepository.XSD_DOM_ELEMENT),superType.<Integer>getData(MetadataRepository.XSD_LINE_NUMBER),superType.<Integer>getData(MetadataRepository.XSD_COLUMN_NUMBER),ValidationError.TYPE_CANNOT_OVERRIDE_SUPER_TYPE_KEY);
            }
          }
        }
      }
    }
  }
  for (  FieldMetadata value : fieldMetadata.values()) {
    value.validate(handler);
  }
  for (  FieldMetadata keyField : keyFields.values()) {
    int errorCount=handler.getErrorCount();
    keyField.validate(handler);
    if (handler.getErrorCount() > errorCount) {
      continue;
    }
    FieldMetadata frozenField=keyField.freeze(handler);
    if (frozenField.isMany()) {
      handler.error(frozenField,"String_Node_Str",frozenField.<Element>getData(MetadataRepository.XSD_DOM_ELEMENT),frozenField.<Integer>getData(MetadataRepository.XSD_LINE_NUMBER),frozenField.<Integer>getData(MetadataRepository.XSD_COLUMN_NUMBER),ValidationError.FIELD_KEY_CANNOT_BE_REPEATABLE);
    }
    if (!frozenField.isMandatory()) {
      handler.error(frozenField,"String_Node_Str",frozenField.<Element>getData(MetadataRepository.XSD_DOM_ELEMENT),frozenField.<Integer>getData(MetadataRepository.XSD_LINE_NUMBER),frozenField.<Integer>getData(MetadataRepository.XSD_COLUMN_NUMBER),ValidationError.FIELD_KEY_MUST_BE_MANDATORY);
    }
  }
  for (  FieldMetadata pkInfo : primaryKeyInfo) {
    if (!this.equals(pkInfo.getContainingType())) {
      handler.error(this,"String_Node_Str",pkInfo.<Element>getData(MetadataRepository.XSD_DOM_ELEMENT),pkInfo.<Integer>getData(MetadataRepository.XSD_LINE_NUMBER),pkInfo.<Integer>getData(MetadataRepository.XSD_COLUMN_NUMBER),ValidationError.PRIMARY_KEY_INFO_NOT_IN_ENTITY);
      continue;
    }
    int previousErrorCount=handler.getErrorCount();
    pkInfo.validate(handler);
    if (handler.getErrorCount() == previousErrorCount) {
      if (pkInfo.isMany()) {
        handler.error(this,"String_Node_Str",pkInfo.<Element>getData(MetadataRepository.XSD_DOM_ELEMENT),pkInfo.<Integer>getData(MetadataRepository.XSD_LINE_NUMBER),pkInfo.<Integer>getData(MetadataRepository.XSD_COLUMN_NUMBER),ValidationError.PRIMARY_KEY_INFO_CANNOT_BE_REPEATABLE);
        continue;
      }
      if (!isPrimitiveTypeField(pkInfo)) {
        handler.warning(this,"String_Node_Str",pkInfo.<Element>getData(MetadataRepository.XSD_DOM_ELEMENT),pkInfo.<Integer>getData(MetadataRepository.XSD_LINE_NUMBER),pkInfo.<Integer>getData(MetadataRepository.XSD_COLUMN_NUMBER),ValidationError.PRIMARY_KEY_INFO_TYPE_NOT_PRIMITIVE);
      }
    }
  }
  for (  FieldMetadata lookupField : lookupFields) {
    int errorCount=handler.getErrorCount();
    lookupField.validate(handler);
    if (handler.getErrorCount() > errorCount) {
      continue;
    }
    if (!this.equals(lookupField.getContainingType())) {
      handler.error(this,"String_Node_Str",lookupField.<Element>getData(MetadataRepository.XSD_DOM_ELEMENT),lookupField.<Integer>getData(MetadataRepository.XSD_LINE_NUMBER),lookupField.<Integer>getData(MetadataRepository.XSD_COLUMN_NUMBER),ValidationError.LOOKUP_FIELD_NOT_IN_ENTITY);
      continue;
    }
    if (handler.getErrorCount() == originalErrorCount) {
      lookupField.getContainingType().freeze(handler);
      if (lookupField.isKey()) {
        handler.error(this,"String_Node_Str",lookupField.<Element>getData(MetadataRepository.XSD_DOM_ELEMENT),lookupField.<Integer>getData(MetadataRepository.XSD_LINE_NUMBER),lookupField.<Integer>getData(MetadataRepository.XSD_COLUMN_NUMBER),ValidationError.LOOKUP_FIELD_CANNOT_BE_KEY);
        continue;
      }
      lookupField.validate(handler);
      if (!isPrimitiveTypeField(lookupField)) {
        handler.error(this,"String_Node_Str",lookupField.<Element>getData(MetadataRepository.XSD_DOM_ELEMENT),lookupField.<Integer>getData(MetadataRepository.XSD_LINE_NUMBER),lookupField.<Integer>getData(MetadataRepository.XSD_COLUMN_NUMBER),ValidationError.LOOKUP_FIELD_MUST_BE_SIMPLE_TYPE);
      }
    }
  }
  isValidated=true;
}