Program: 67438
Project: 67438
Buggy source:
public ArrayList<Property> getFieldPropertiesForClass(JavaClass cls,TypeInfo info,boolean onlyPublic){
  ArrayList<Property> properties=new ArrayList<Property>();
  if (cls == null) {
    return properties;
  }
  boolean hasAnyAttribteProperty=false;
  for (Iterator<JavaField> fieldIt=cls.getDeclaredFields().iterator(); fieldIt.hasNext(); ) {
    JavaField nextField=fieldIt.next();
    if (!helper.isAnnotationPresent(nextField,XmlTransient.class)) {
      int modifiers=nextField.getModifiers();
      if (!Modifier.isStatic(modifiers) && !Modifier.isTransient(modifiers) && ((Modifier.isPublic(nextField.getModifiers()) && onlyPublic) || !onlyPublic)) {
        Property property=null;
        if (helper.isAnnotationPresent((JavaHasAnnotations)nextField,XmlElements.class)) {
          property=new ChoiceProperty(helper);
          property.setElement((JavaHasAnnotations)nextField);
          XmlElements xmlElements=(XmlElements)helper.getAnnotation(property.getElement(),XmlElements.class);
          XmlElement[] elements=xmlElements.value();
          ArrayList<Property> choiceProperties=new ArrayList<Property>(elements.length);
          validateElementIsInPropOrder(info,nextField.getName());
          for (int i=0; i < elements.length; i++) {
            XmlElement next=elements[i];
            Property choiceProp=new Property();
            String name=next.name();
            String namespace=next.namespace();
            QName qName=null;
            if (name.equals("String_Node_Str")) {
              name=nextField.getName();
            }
            if (!namespace.equals("String_Node_Str")) {
              qName=new QName(namespace,name);
            }
 else {
              NamespaceInfo namespaceInfo=getNamespaceInfoForPackage(cls.getPackage());
              if (namespaceInfo.isElementFormQualified()) {
                qName=new QName(namespaceInfo.getNamespace(),name);
              }
 else {
                qName=new QName(name);
              }
            }
            choiceProp.setPropertyName(property.getPropertyName());
            Class typeClass=next.type();
            if (typeClass.equals(XmlElement.DEFAULT.class)) {
              JavaClass type=nextField.getResolvedType();
              if (isCollectionType(type)) {
                if (type.hasActualTypeArguments()) {
                  JavaClass itemType=(JavaClass)type.getActualTypeArguments().toArray()[0];
                  choiceProp.setType(itemType);
                }
 else {
                  choiceProp.setType(helper.getJavaClass("String_Node_Str"));
                }
              }
 else {
                choiceProp.setType(type);
              }
            }
 else {
              choiceProp.setType(helper.getJavaClass(next.type()));
            }
            choiceProp.setSchemaName(qName);
            choiceProp.setSchemaType(getSchemaTypeFor(helper.getJavaClass(next.type())));
            choiceProp.setElement(property.getElement());
            choiceProperties.add(choiceProp);
          }
          ((ChoiceProperty)property).setChoiceProperties(choiceProperties);
        }
 else         if (helper.isAnnotationPresent((JavaHasAnnotations)nextField,XmlAnyElement.class)) {
          property=new AnyProperty(helper);
          property.setElement((JavaHasAnnotations)nextField);
          XmlAnyElement anyElement=(XmlAnyElement)helper.getAnnotation((JavaHasAnnotations)nextField,XmlAnyElement.class);
          ((AnyProperty)property).setLax(anyElement.lax());
          ((AnyProperty)property).setDomHandlerClass(anyElement.value());
        }
 else         if (helper.isAnnotationPresent((JavaHasAnnotations)nextField,XmlElementRef.class) || helper.isAnnotationPresent((JavaHasAnnotations)nextField,XmlElementRefs.class)) {
          property=new ReferenceProperty(helper);
          property.setElement(nextField);
          XmlElementRef[] elementRefs;
          XmlElementRef ref=(XmlElementRef)helper.getAnnotation((JavaHasAnnotations)nextField,XmlElementRef.class);
          if (ref != null) {
            elementRefs=new XmlElementRef[]{ref};
          }
 else {
            XmlElementRefs refs=(XmlElementRefs)helper.getAnnotation((JavaHasAnnotations)nextField,XmlElementRefs.class);
            elementRefs=refs.value();
            info.setHasElementRefs(true);
          }
          validateElementIsInPropOrder(info,nextField.getName());
          for (          XmlElementRef nextRef : elementRefs) {
            JavaClass type=nextField.getResolvedType();
            String typeName=type.getQualifiedName();
            property.setType(type);
            if (isCollectionType(property)) {
              if (type.hasActualTypeArguments()) {
                type=(JavaClass)type.getActualTypeArguments().toArray()[0];
                typeName=type.getQualifiedName();
              }
            }
            if (nextRef.type() != XmlElementRef.DEFAULT.class) {
              typeName=helper.getJavaClass(nextRef.type()).getQualifiedName();
            }
            ElementDeclaration referencedElement=this.xmlRootElements.get(typeName);
            if (referencedElement != null) {
              addReferencedElement((ReferenceProperty)property,referencedElement);
            }
 else {
              String name=nextRef.name();
              String namespace=nextRef.namespace();
              if (namespace.equals("String_Node_Str")) {
                namespace="String_Node_Str";
              }
              QName qname=new QName(namespace,name);
              referencedElement=this.globalElements.get(qname);
              if (referencedElement != null) {
                addReferencedElement((ReferenceProperty)property,referencedElement);
              }
 else {
                throw org.eclipse.persistence.exceptions.JAXBException.invalidElementRef(property.getPropertyName(),cls.getName());
              }
            }
          }
        }
 else {
          property=new Property(helper);
          property.setElement((JavaHasAnnotations)nextField);
        }
        if (helper.isAnnotationPresent((JavaHasAnnotations)nextField,XmlMixed.class)) {
          info.setMixed(true);
        }
        JavaClass ptype=(JavaClass)nextField.getResolvedType();
        if (!helper.isAnnotationPresent(ptype,XmlTransient.class)) {
          property.setType(ptype);
        }
 else {
          JavaClass parent=ptype.getSuperclass();
          while (parent != null) {
            if (parent.getName().equals("String_Node_Str")) {
              property.setType(parent);
              break;
            }
            if (!helper.isAnnotationPresent(parent,XmlTransient.class)) {
              property.setType(parent);
              break;
            }
            parent=parent.getSuperclass();
          }
        }
        if (helper.isAnnotationPresent(property.getElement(),XmlJavaTypeAdapter.class)) {
          XmlJavaTypeAdapter adapter=(XmlJavaTypeAdapter)helper.getAnnotation(property.getElement(),XmlJavaTypeAdapter.class);
          property.setAdapterClass(adapter.value());
        }
 else         if (info.getAdaptersByClass().get(ptype) != null) {
          property.setAdapterClass(info.getAdapterClass(ptype));
        }
        if (property.hasAdapterClass()) {
          ptype=property.getValueType();
        }
        property.setGenericType(helper.getGenericType(nextField));
        property.setPropertyName(nextField.getName());
        if (helper.isAnnotationPresent(property.getElement(),XmlAttachmentRef.class) && areEquals(ptype,JAVAX_ACTIVATION_DATAHANDLER)) {
          property.setIsSwaAttachmentRef(true);
          property.setSchemaType(XMLConstants.SWA_REF_QNAME);
        }
 else         if (areEquals(ptype,JAVAX_ACTIVATION_DATAHANDLER) || areEquals(ptype,byte[].class) || areEquals(ptype,Byte[].class)|| areEquals(ptype,Image.class)|| areEquals(ptype,Source.class)|| areEquals(ptype,JAVAX_MAIL_INTERNET_MIMEMULTIPART)) {
          property.setIsMtomAttachment(true);
          property.setSchemaType(XMLConstants.BASE_64_BINARY_QNAME);
        }
        if (helper.isAnnotationPresent(property.getElement(),XmlMimeType.class)) {
          property.setMimeType(((XmlMimeType)helper.getAnnotation(property.getElement(),XmlMimeType.class)).value());
        }
        if (helper.isAnnotationPresent(property.getElement(),XmlSchemaType.class)) {
          XmlSchemaType schemaType=(XmlSchemaType)helper.getAnnotation(property.getElement(),XmlSchemaType.class);
          QName schemaTypeQname=new QName(schemaType.namespace(),schemaType.name());
          property.setSchemaType(schemaTypeQname);
        }
        if (helper.isAnnotationPresent(property.getElement(),XmlAttribute.class)) {
          property.setIsAttribute(true);
          property.setIsRequired(((XmlAttribute)helper.getAnnotation(property.getElement(),XmlAttribute.class)).required());
        }
        if (helper.isAnnotationPresent(property.getElement(),XmlAnyAttribute.class)) {
          if (hasAnyAttribteProperty) {
            throw org.eclipse.persistence.exceptions.JAXBException.multipleAnyAttributeMapping(cls.getName());
          }
          if (!ptype.getName().equals("String_Node_Str")) {
            throw org.eclipse.persistence.exceptions.JAXBException.anyAttributeOnNonMap(property.getPropertyName());
          }
          property.setIsAttribute(true);
          hasAnyAttribteProperty=true;
        }
        if (ptype.isPrimitive()) {
          property.setIsRequired(true);
        }
 else         if (helper.isAnnotationPresent(property.getElement(),XmlElement.class)) {
          XmlElement xmlElement=(XmlElement)helper.getAnnotation(property.getElement(),XmlElement.class);
          property.setIsRequired(xmlElement.required());
          property.setNillable(xmlElement.nillable());
          validateElementIsInPropOrder(info,property.getPropertyName());
        }
        if (helper.isAnnotationPresent(property.getElement(),XmlValue.class)) {
          info.setXmlValueProperty(property);
          validateXmlValueFieldOrProperty(cls,property,ptype,nextField.getName());
        }
        property.setSchemaName(getQNameForProperty(Introspector.decapitalize(nextField.getName()),nextField,getNamespaceInfoForPackage(cls.getPackage())));
        properties.add(property);
      }
    }
 else {
      List<String> propOrderList=Arrays.asList(info.getPropOrder());
      if (propOrderList.contains(nextField.getName())) {
        throw JAXBException.transientInProporder(nextField.getName());
      }
    }
  }
  return properties;
}

Fixed version (ground truth):
public ArrayList<Property> getFieldPropertiesForClass(JavaClass cls,TypeInfo info,boolean onlyPublic){
  ArrayList<Property> properties=new ArrayList<Property>();
  if (cls == null) {
    return properties;
  }
  boolean hasAnyAttribteProperty=false;
  for (Iterator<JavaField> fieldIt=cls.getDeclaredFields().iterator(); fieldIt.hasNext(); ) {
    JavaField nextField=fieldIt.next();
    if (!helper.isAnnotationPresent(nextField,XmlTransient.class)) {
      int modifiers=nextField.getModifiers();
      if (!Modifier.isStatic(modifiers) && !Modifier.isTransient(modifiers) && ((Modifier.isPublic(nextField.getModifiers()) && onlyPublic) || !onlyPublic)) {
        Property property=null;
        if (helper.isAnnotationPresent((JavaHasAnnotations)nextField,XmlElements.class)) {
          property=new ChoiceProperty(helper);
          property.setElement((JavaHasAnnotations)nextField);
          XmlElements xmlElements=(XmlElements)helper.getAnnotation(property.getElement(),XmlElements.class);
          XmlElement[] elements=xmlElements.value();
          ArrayList<Property> choiceProperties=new ArrayList<Property>(elements.length);
          validateElementIsInPropOrder(info,nextField.getName());
          for (int i=0; i < elements.length; i++) {
            XmlElement next=elements[i];
            Property choiceProp=new Property();
            String name=next.name();
            String namespace=next.namespace();
            QName qName=null;
            if (name.equals("String_Node_Str")) {
              name=nextField.getName();
            }
            if (!namespace.equals("String_Node_Str")) {
              qName=new QName(namespace,name);
            }
 else {
              NamespaceInfo namespaceInfo=getNamespaceInfoForPackage(cls.getPackage());
              if (namespaceInfo.isElementFormQualified()) {
                qName=new QName(namespaceInfo.getNamespace(),name);
              }
 else {
                qName=new QName(name);
              }
            }
            choiceProp.setPropertyName(property.getPropertyName());
            Class typeClass=next.type();
            if (typeClass.equals(XmlElement.DEFAULT.class)) {
              JavaClass type=nextField.getResolvedType();
              if (isCollectionType(type)) {
                if (type.hasActualTypeArguments()) {
                  JavaClass itemType=(JavaClass)type.getActualTypeArguments().toArray()[0];
                  choiceProp.setType(itemType);
                }
 else {
                  choiceProp.setType(helper.getJavaClass("String_Node_Str"));
                }
              }
 else {
                choiceProp.setType(type);
              }
            }
 else {
              choiceProp.setType(helper.getJavaClass(next.type()));
            }
            choiceProp.setSchemaName(qName);
            choiceProp.setSchemaType(getSchemaTypeFor(helper.getJavaClass(next.type())));
            choiceProp.setElement(property.getElement());
            choiceProperties.add(choiceProp);
          }
          ((ChoiceProperty)property).setChoiceProperties(choiceProperties);
        }
 else         if (helper.isAnnotationPresent((JavaHasAnnotations)nextField,XmlAnyElement.class)) {
          property=new AnyProperty(helper);
          property.setElement((JavaHasAnnotations)nextField);
          XmlAnyElement anyElement=(XmlAnyElement)helper.getAnnotation((JavaHasAnnotations)nextField,XmlAnyElement.class);
          ((AnyProperty)property).setLax(anyElement.lax());
          ((AnyProperty)property).setDomHandlerClass(anyElement.value());
        }
 else         if (helper.isAnnotationPresent((JavaHasAnnotations)nextField,XmlElementRef.class) || helper.isAnnotationPresent((JavaHasAnnotations)nextField,XmlElementRefs.class)) {
          property=new ReferenceProperty(helper);
          property.setElement(nextField);
          XmlElementRef[] elementRefs;
          XmlElementRef ref=(XmlElementRef)helper.getAnnotation((JavaHasAnnotations)nextField,XmlElementRef.class);
          if (ref != null) {
            elementRefs=new XmlElementRef[]{ref};
          }
 else {
            XmlElementRefs refs=(XmlElementRefs)helper.getAnnotation((JavaHasAnnotations)nextField,XmlElementRefs.class);
            elementRefs=refs.value();
            info.setHasElementRefs(true);
          }
          validateElementIsInPropOrder(info,nextField.getName());
          for (          XmlElementRef nextRef : elementRefs) {
            JavaClass type=nextField.getResolvedType();
            String typeName=type.getQualifiedName();
            property.setType(type);
            if (isCollectionType(property)) {
              if (type.hasActualTypeArguments()) {
                type=(JavaClass)type.getActualTypeArguments().toArray()[0];
                typeName=type.getQualifiedName();
              }
            }
            if (nextRef.type() != XmlElementRef.DEFAULT.class) {
              typeName=helper.getJavaClass(nextRef.type()).getQualifiedName();
            }
            ElementDeclaration referencedElement=this.xmlRootElements.get(typeName);
            if (referencedElement != null) {
              addReferencedElement((ReferenceProperty)property,referencedElement);
            }
 else {
              String name=nextRef.name();
              String namespace=nextRef.namespace();
              if (namespace.equals("String_Node_Str")) {
                namespace="String_Node_Str";
              }
              QName qname=new QName(namespace,name);
              referencedElement=this.globalElements.get(qname);
              if (referencedElement != null) {
                addReferencedElement((ReferenceProperty)property,referencedElement);
              }
 else {
                throw org.eclipse.persistence.exceptions.JAXBException.invalidElementRef(property.getPropertyName(),cls.getName());
              }
            }
          }
        }
 else {
          property=new Property(helper);
          property.setElement((JavaHasAnnotations)nextField);
        }
        if (helper.isAnnotationPresent((JavaHasAnnotations)nextField,XmlMixed.class)) {
          info.setMixed(true);
          property.setMixedContent(true);
        }
        JavaClass ptype=(JavaClass)nextField.getResolvedType();
        if (!helper.isAnnotationPresent(ptype,XmlTransient.class)) {
          property.setType(ptype);
        }
 else {
          JavaClass parent=ptype.getSuperclass();
          while (parent != null) {
            if (parent.getName().equals("String_Node_Str")) {
              property.setType(parent);
              break;
            }
            if (!helper.isAnnotationPresent(parent,XmlTransient.class)) {
              property.setType(parent);
              break;
            }
            parent=parent.getSuperclass();
          }
        }
        if (helper.isAnnotationPresent(property.getElement(),XmlJavaTypeAdapter.class)) {
          XmlJavaTypeAdapter adapter=(XmlJavaTypeAdapter)helper.getAnnotation(property.getElement(),XmlJavaTypeAdapter.class);
          property.setAdapterClass(adapter.value());
        }
 else         if (info.getAdaptersByClass().get(ptype) != null) {
          property.setAdapterClass(info.getAdapterClass(ptype));
        }
        if (property.hasAdapterClass()) {
          ptype=property.getValueType();
        }
        property.setGenericType(helper.getGenericType(nextField));
        property.setPropertyName(nextField.getName());
        if (helper.isAnnotationPresent(property.getElement(),XmlAttachmentRef.class) && areEquals(ptype,JAVAX_ACTIVATION_DATAHANDLER)) {
          property.setIsSwaAttachmentRef(true);
          property.setSchemaType(XMLConstants.SWA_REF_QNAME);
        }
 else         if (areEquals(ptype,JAVAX_ACTIVATION_DATAHANDLER) || areEquals(ptype,byte[].class) || areEquals(ptype,Byte[].class)|| areEquals(ptype,Image.class)|| areEquals(ptype,Source.class)|| areEquals(ptype,JAVAX_MAIL_INTERNET_MIMEMULTIPART)) {
          property.setIsMtomAttachment(true);
          property.setSchemaType(XMLConstants.BASE_64_BINARY_QNAME);
        }
        if (helper.isAnnotationPresent(property.getElement(),XmlMimeType.class)) {
          property.setMimeType(((XmlMimeType)helper.getAnnotation(property.getElement(),XmlMimeType.class)).value());
        }
        if (helper.isAnnotationPresent(property.getElement(),XmlSchemaType.class)) {
          XmlSchemaType schemaType=(XmlSchemaType)helper.getAnnotation(property.getElement(),XmlSchemaType.class);
          QName schemaTypeQname=new QName(schemaType.namespace(),schemaType.name());
          property.setSchemaType(schemaTypeQname);
        }
        if (helper.isAnnotationPresent(property.getElement(),XmlAttribute.class)) {
          property.setIsAttribute(true);
          property.setIsRequired(((XmlAttribute)helper.getAnnotation(property.getElement(),XmlAttribute.class)).required());
        }
        if (helper.isAnnotationPresent(property.getElement(),XmlAnyAttribute.class)) {
          if (hasAnyAttribteProperty) {
            throw org.eclipse.persistence.exceptions.JAXBException.multipleAnyAttributeMapping(cls.getName());
          }
          if (!ptype.getName().equals("String_Node_Str")) {
            throw org.eclipse.persistence.exceptions.JAXBException.anyAttributeOnNonMap(property.getPropertyName());
          }
          property.setIsAttribute(true);
          hasAnyAttribteProperty=true;
        }
        if (ptype.isPrimitive()) {
          property.setIsRequired(true);
        }
 else         if (helper.isAnnotationPresent(property.getElement(),XmlElement.class)) {
          XmlElement xmlElement=(XmlElement)helper.getAnnotation(property.getElement(),XmlElement.class);
          property.setIsRequired(xmlElement.required());
          property.setNillable(xmlElement.nillable());
          validateElementIsInPropOrder(info,property.getPropertyName());
        }
        if (helper.isAnnotationPresent(property.getElement(),XmlValue.class)) {
          info.setXmlValueProperty(property);
          validateXmlValueFieldOrProperty(cls,property,ptype,nextField.getName());
        }
        property.setSchemaName(getQNameForProperty(Introspector.decapitalize(nextField.getName()),nextField,getNamespaceInfoForPackage(cls.getPackage())));
        properties.add(property);
      }
    }
 else {
      List<String> propOrderList=Arrays.asList(info.getPropOrder());
      if (propOrderList.contains(nextField.getName())) {
        throw JAXBException.transientInProporder(nextField.getName());
      }
    }
  }
  return properties;
}