Program: 146046
Project: 146046
Buggy source:
private FieldMetadata createFieldMetadata(XSDElementDeclaration element,ComplexTypeMetadata containingType){
  String fieldName=element.getName();
  int minOccurs=((XSDParticle)element.getContainer()).getMinOccurs();
  int maxOccurs=((XSDParticle)element.getContainer()).getMaxOccurs();
  if (maxOccurs > 0 && minOccurs > maxOccurs) {
    throw new IllegalArgumentException("String_Node_Str" + element.getQName() + "String_Node_Str"+ containingType+ "String_Node_Str");
  }
  boolean isMany=maxOccurs == -1 || maxOccurs > 1;
  XmlSchemaAnnotationProcessorState state=new XmlSchemaAnnotationProcessorState();
  try {
    XSDAnnotation annotation=element.getAnnotation();
    for (    XmlSchemaAnnotationProcessor processor : XML_ANNOTATIONS_PROCESSORS) {
      processor.process(this,containingType,annotation,state);
    }
  }
 catch (  Exception e) {
    throw new RuntimeException("String_Node_Str" + fieldName + "String_Node_Str"+ containingType.getName()+ "String_Node_Str",e);
  }
  boolean isMandatory=minOccurs > 0;
  boolean isContained=false;
  boolean isReference=state.isReference();
  boolean fkIntegrity=state.isFkIntegrity();
  boolean fkIntegrityOverride=state.isFkIntegrityOverride();
  FieldMetadata foreignKeyInfo=state.getForeignKeyInfo();
  TypeMetadata fieldType=state.getFieldType();
  FieldMetadata referencedField=state.getReferencedField();
  TypeMetadata referencedType=state.getReferencedType();
  List<String> hideUsers=state.getHide();
  List<String> allowWriteUsers=state.getAllowWrite();
  if (foreignKeyInfo != null && fieldType == null) {
    throw new IllegalArgumentException("String_Node_Str" + fieldName + "String_Node_Str"+ containingType.getName()+ "String_Node_Str");
  }
  XSDTypeDefinition schemaType=element.getType();
  if (schemaType instanceof XSDSimpleTypeDefinition) {
    XSDSimpleTypeDefinition simpleSchemaType=(XSDSimpleTypeDefinition)schemaType;
    XSDSimpleTypeDefinition content=simpleSchemaType.getBaseTypeDefinition();
    if (schemaType.getQName() != null) {
      fieldType=new SoftTypeRef(this,schemaType.getTargetNamespace(),schemaType.getName(),false);
    }
    if (isReference) {
      ReferenceFieldMetadata referenceField=new ReferenceFieldMetadata(containingType,false,isMany,isMandatory,fieldName,(ComplexTypeMetadata)referencedType,referencedField,foreignKeyInfo,fkIntegrity,fkIntegrityOverride,fieldType,allowWriteUsers,hideUsers);
      referenceField.setData(XSD_LINE_NUMBER,XSDParser.getStartLine(element.getElement()));
      referenceField.setData(XSD_COLUMN_NUMBER,XSDParser.getStartColumn(element.getElement()));
      referenceField.setData(XSD_DOM_ELEMENT,element.getElement());
      return referenceField;
    }
    if (content != null) {
      if (fieldType == null) {
        fieldType=new SoftTypeRef(this,content.getTargetNamespace(),content.getName(),false);
      }
      if (content.getFacets().size() > 0) {
        boolean isEnumeration=false;
        for (int i=0; i < content.getFacets().size(); i++) {
          XSDConstrainingFacet item=content.getFacets().get(i);
          if (item instanceof XSDEnumerationFacet) {
            isEnumeration=true;
          }
        }
        if (isEnumeration) {
          EnumerationFieldMetadata enumField=new EnumerationFieldMetadata(containingType,false,isMany,isMandatory,fieldName,fieldType,allowWriteUsers,hideUsers);
          enumField.setData(XSD_LINE_NUMBER,XSDParser.getStartLine(element.getElement()));
          enumField.setData(XSD_COLUMN_NUMBER,XSDParser.getStartColumn(element.getElement()));
          enumField.setData(XSD_DOM_ELEMENT,element.getElement());
          return enumField;
        }
 else {
          FieldMetadata field=new SimpleTypeFieldMetadata(containingType,false,isMany,isMandatory,fieldName,fieldType,allowWriteUsers,hideUsers);
          field.setData(XSD_LINE_NUMBER,XSDParser.getStartLine(element.getElement()));
          field.setData(XSD_COLUMN_NUMBER,XSDParser.getStartColumn(element.getElement()));
          field.setData(XSD_DOM_ELEMENT,element.getElement());
          return field;
        }
      }
 else {
        FieldMetadata field=new SimpleTypeFieldMetadata(containingType,false,isMany,isMandatory,fieldName,fieldType,allowWriteUsers,hideUsers);
        field.setData(XSD_LINE_NUMBER,XSDParser.getStartLine(element.getElement()));
        field.setData(XSD_COLUMN_NUMBER,XSDParser.getStartColumn(element.getElement()));
        field.setData(XSD_DOM_ELEMENT,element.getElement());
        return field;
      }
    }
  }
  if (fieldType == null) {
    String qName=element.getType() == null ? null : element.getType().getQName();
    if (qName != null) {
      TypeMetadata metadata=getType(element.getType().getTargetNamespace(),element.getType().getName());
      if (metadata != null) {
        referencedType=new ContainedComplexTypeRef(currentTypeStack.peek(),targetNamespace,element.getName(),new SoftTypeRef(this,targetNamespace,schemaType.getName(),false));
        isContained=true;
      }
 else {
        if (schemaType == null) {
          throw new IllegalArgumentException("String_Node_Str" + fieldName + "String_Node_Str"+ containingType.getName()+ "String_Node_Str");
        }
        if (schemaType instanceof XSDComplexTypeDefinition) {
          referencedType=new ContainedComplexTypeRef(currentTypeStack.peek(),targetNamespace,element.getName(),new SoftTypeRef(this,targetNamespace,schemaType.getName(),false));
          isContained=true;
        }
 else         if (schemaType instanceof XSDSimpleTypeDefinition) {
          fieldType=new SoftTypeRef(this,schemaType.getTargetNamespace(),schemaType.getName(),false);
          XmlSchemaWalker.walk(schemaType,this);
        }
 else {
          throw new NotImplementedException("String_Node_Str" + schemaType.getClass() + "String_Node_Str");
        }
      }
    }
 else {
      isContained=true;
      XSDElementDeclaration refName=element.getResolvedElementDeclaration();
      if (schemaType != null) {
        referencedType=new ContainedComplexTypeMetadata(currentTypeStack.peek(),targetNamespace,ANONYMOUS_PREFIX + String.valueOf(anonymousCounter++));
        fieldType=referencedType;
        isContained=true;
        currentTypeStack.push((ComplexTypeMetadata)referencedType);
        XmlSchemaWalker.walk(schemaType,this);
        currentTypeStack.pop();
      }
 else       if (refName != null) {
        SoftTypeRef reference=new SoftTypeRef(this,refName.getTargetNamespace(),refName.getName(),true);
        referencedType=new ContainedComplexTypeRef(currentTypeStack.peek(),targetNamespace,element.getName(),reference);
        fieldType=referencedType;
      }
 else {
        throw new NotImplementedException();
      }
    }
  }
  if (isContained) {
    ContainedTypeFieldMetadata containedField=new ContainedTypeFieldMetadata(containingType,isMany,isMandatory,fieldName,(ContainedComplexTypeMetadata)referencedType,allowWriteUsers,hideUsers);
    containedField.setData(XSD_LINE_NUMBER,XSDParser.getStartLine(element.getElement()));
    containedField.setData(XSD_COLUMN_NUMBER,XSDParser.getStartColumn(element.getElement()));
    containedField.setData(XSD_DOM_ELEMENT,element.getElement());
    return containedField;
  }
 else {
    FieldMetadata field=new SimpleTypeFieldMetadata(containingType,false,isMany,isMandatory,fieldName,fieldType,allowWriteUsers,hideUsers);
    field.setData(XSD_LINE_NUMBER,XSDParser.getStartLine(element.getElement()));
    field.setData(XSD_COLUMN_NUMBER,XSDParser.getStartColumn(element.getElement()));
    field.setData(XSD_DOM_ELEMENT,element.getElement());
    return field;
  }
}

Fixed version (ground truth):
private FieldMetadata createFieldMetadata(XSDElementDeclaration element,ComplexTypeMetadata containingType){
  String fieldName=element.getName();
  int minOccurs=((XSDParticle)element.getContainer()).getMinOccurs();
  int maxOccurs=((XSDParticle)element.getContainer()).getMaxOccurs();
  if (maxOccurs > 0 && minOccurs > maxOccurs) {
    throw new IllegalArgumentException("String_Node_Str" + element.getQName() + "String_Node_Str"+ containingType+ "String_Node_Str");
  }
  boolean isMany=maxOccurs == -1 || maxOccurs > 1;
  XmlSchemaAnnotationProcessorState state=new XmlSchemaAnnotationProcessorState();
  try {
    XSDAnnotation annotation=element.getAnnotation();
    for (    XmlSchemaAnnotationProcessor processor : XML_ANNOTATIONS_PROCESSORS) {
      processor.process(this,containingType,annotation,state);
    }
  }
 catch (  Exception e) {
    throw new RuntimeException("String_Node_Str" + fieldName + "String_Node_Str"+ containingType.getName()+ "String_Node_Str",e);
  }
  boolean isMandatory=minOccurs > 0;
  boolean isContained=false;
  boolean isReference=state.isReference();
  boolean fkIntegrity=state.isFkIntegrity();
  boolean fkIntegrityOverride=state.isFkIntegrityOverride();
  FieldMetadata foreignKeyInfo=state.getForeignKeyInfo();
  TypeMetadata fieldType=state.getFieldType();
  FieldMetadata referencedField=state.getReferencedField();
  TypeMetadata referencedType=state.getReferencedType();
  List<String> hideUsers=state.getHide();
  List<String> allowWriteUsers=state.getAllowWrite();
  if (foreignKeyInfo != null && fieldType == null) {
    throw new IllegalArgumentException("String_Node_Str" + fieldName + "String_Node_Str"+ containingType.getName()+ "String_Node_Str");
  }
  XSDTypeDefinition schemaType=element.getType();
  if (schemaType instanceof XSDSimpleTypeDefinition) {
    XSDSimpleTypeDefinition simpleSchemaType=(XSDSimpleTypeDefinition)schemaType;
    XSDSimpleTypeDefinition content=simpleSchemaType.getBaseTypeDefinition();
    if (schemaType.getQName() != null) {
      fieldType=new SoftTypeRef(this,schemaType.getTargetNamespace(),schemaType.getName(),false);
      fieldType.setData(XSD_LINE_NUMBER,XSDParser.getStartLine(element.getElement()));
      fieldType.setData(XSD_COLUMN_NUMBER,XSDParser.getStartColumn(element.getElement()));
      fieldType.setData(XSD_DOM_ELEMENT,element.getElement());
    }
    if (isReference) {
      ReferenceFieldMetadata referenceField=new ReferenceFieldMetadata(containingType,false,isMany,isMandatory,fieldName,(ComplexTypeMetadata)referencedType,referencedField,foreignKeyInfo,fkIntegrity,fkIntegrityOverride,fieldType,allowWriteUsers,hideUsers);
      referenceField.setData(XSD_LINE_NUMBER,XSDParser.getStartLine(element.getElement()));
      referenceField.setData(XSD_COLUMN_NUMBER,XSDParser.getStartColumn(element.getElement()));
      referenceField.setData(XSD_DOM_ELEMENT,element.getElement());
      return referenceField;
    }
    if (content != null) {
      if (fieldType == null) {
        fieldType=new SoftTypeRef(this,content.getTargetNamespace(),content.getName(),false);
      }
      if (content.getFacets().size() > 0) {
        boolean isEnumeration=false;
        for (int i=0; i < content.getFacets().size(); i++) {
          XSDConstrainingFacet item=content.getFacets().get(i);
          if (item instanceof XSDEnumerationFacet) {
            isEnumeration=true;
          }
        }
        if (isEnumeration) {
          EnumerationFieldMetadata enumField=new EnumerationFieldMetadata(containingType,false,isMany,isMandatory,fieldName,fieldType,allowWriteUsers,hideUsers);
          enumField.setData(XSD_LINE_NUMBER,XSDParser.getStartLine(element.getElement()));
          enumField.setData(XSD_COLUMN_NUMBER,XSDParser.getStartColumn(element.getElement()));
          enumField.setData(XSD_DOM_ELEMENT,element.getElement());
          return enumField;
        }
 else {
          FieldMetadata field=new SimpleTypeFieldMetadata(containingType,false,isMany,isMandatory,fieldName,fieldType,allowWriteUsers,hideUsers);
          field.setData(XSD_LINE_NUMBER,XSDParser.getStartLine(element.getElement()));
          field.setData(XSD_COLUMN_NUMBER,XSDParser.getStartColumn(element.getElement()));
          field.setData(XSD_DOM_ELEMENT,element.getElement());
          return field;
        }
      }
 else {
        FieldMetadata field=new SimpleTypeFieldMetadata(containingType,false,isMany,isMandatory,fieldName,fieldType,allowWriteUsers,hideUsers);
        field.setData(XSD_LINE_NUMBER,XSDParser.getStartLine(element.getElement()));
        field.setData(XSD_COLUMN_NUMBER,XSDParser.getStartColumn(element.getElement()));
        field.setData(XSD_DOM_ELEMENT,element.getElement());
        return field;
      }
    }
  }
  if (fieldType == null) {
    String qName=element.getType() == null ? null : element.getType().getQName();
    if (qName != null) {
      TypeMetadata metadata=getType(element.getType().getTargetNamespace(),element.getType().getName());
      if (metadata != null) {
        referencedType=new ContainedComplexTypeRef(currentTypeStack.peek(),targetNamespace,element.getName(),new SoftTypeRef(this,targetNamespace,schemaType.getName(),false));
        isContained=true;
      }
 else {
        if (schemaType == null) {
          throw new IllegalArgumentException("String_Node_Str" + fieldName + "String_Node_Str"+ containingType.getName()+ "String_Node_Str");
        }
        if (schemaType instanceof XSDComplexTypeDefinition) {
          referencedType=new ContainedComplexTypeRef(currentTypeStack.peek(),targetNamespace,element.getName(),new SoftTypeRef(this,targetNamespace,schemaType.getName(),false));
          isContained=true;
        }
 else         if (schemaType instanceof XSDSimpleTypeDefinition) {
          fieldType=new SoftTypeRef(this,schemaType.getTargetNamespace(),schemaType.getName(),false);
          XmlSchemaWalker.walk(schemaType,this);
        }
 else {
          throw new NotImplementedException("String_Node_Str" + schemaType.getClass() + "String_Node_Str");
        }
      }
    }
 else {
      isContained=true;
      XSDElementDeclaration refName=element.getResolvedElementDeclaration();
      if (schemaType != null) {
        referencedType=new ContainedComplexTypeMetadata(currentTypeStack.peek(),targetNamespace,ANONYMOUS_PREFIX + String.valueOf(anonymousCounter++));
        fieldType=referencedType;
        isContained=true;
        currentTypeStack.push((ComplexTypeMetadata)referencedType);
        XmlSchemaWalker.walk(schemaType,this);
        currentTypeStack.pop();
      }
 else       if (refName != null) {
        SoftTypeRef reference=new SoftTypeRef(this,refName.getTargetNamespace(),refName.getName(),true);
        referencedType=new ContainedComplexTypeRef(currentTypeStack.peek(),targetNamespace,element.getName(),reference);
        fieldType=referencedType;
      }
 else {
        throw new NotImplementedException();
      }
    }
  }
  if (isContained) {
    ContainedTypeFieldMetadata containedField=new ContainedTypeFieldMetadata(containingType,isMany,isMandatory,fieldName,(ContainedComplexTypeMetadata)referencedType,allowWriteUsers,hideUsers);
    containedField.setData(XSD_LINE_NUMBER,XSDParser.getStartLine(element.getElement()));
    containedField.setData(XSD_COLUMN_NUMBER,XSDParser.getStartColumn(element.getElement()));
    containedField.setData(XSD_DOM_ELEMENT,element.getElement());
    return containedField;
  }
 else {
    FieldMetadata field=new SimpleTypeFieldMetadata(containingType,false,isMany,isMandatory,fieldName,fieldType,allowWriteUsers,hideUsers);
    field.setData(XSD_LINE_NUMBER,XSDParser.getStartLine(element.getElement()));
    field.setData(XSD_COLUMN_NUMBER,XSDParser.getStartColumn(element.getElement()));
    field.setData(XSD_DOM_ELEMENT,element.getElement());
    return field;
  }
}