Program: 64632
Project: 64632
Buggy source:
Property buildNewProperty(TypeInfo info,JavaClass cls,JavaHasAnnotations javaHasAnnotations,String propertyName,JavaClass ptype){
  Property property=null;
  if (helper.isAnnotationPresent(javaHasAnnotations,XmlElements.class)) {
    property=buildChoiceProperty(javaHasAnnotations);
  }
 else   if (helper.isAnnotationPresent(javaHasAnnotations,XmlElementRef.class) || helper.isAnnotationPresent(javaHasAnnotations,XmlElementRefs.class)) {
    findAndProcessObjectFactory(cls);
    property=buildReferenceProperty(info,javaHasAnnotations,propertyName,ptype);
    if (helper.isAnnotationPresent(javaHasAnnotations,XmlAnyElement.class)) {
      XmlAnyElement anyElement=(XmlAnyElement)helper.getAnnotation(javaHasAnnotations,XmlAnyElement.class);
      property.setIsAny(true);
      if (anyElement.value() != null) {
        property.setDomHandlerClassName(anyElement.value().getName());
      }
      property.setLax(anyElement.lax());
      info.setAnyElementPropertyName(propertyName);
    }
  }
 else   if (helper.isAnnotationPresent(javaHasAnnotations,XmlAnyElement.class)) {
    findAndProcessObjectFactory(cls);
    XmlAnyElement anyElement=(XmlAnyElement)helper.getAnnotation(javaHasAnnotations,XmlAnyElement.class);
    property=new Property(helper);
    property.setIsAny(true);
    if (anyElement.value() != null) {
      property.setDomHandlerClassName(anyElement.value().getName());
    }
    property.setLax(anyElement.lax());
    info.setAnyElementPropertyName(propertyName);
  }
 else   if (helper.isAnnotationPresent(javaHasAnnotations,org.eclipse.persistence.oxm.annotations.XmlTransformation.class) || helper.isAnnotationPresent(javaHasAnnotations,org.eclipse.persistence.oxm.annotations.XmlReadTransformer.class) || helper.isAnnotationPresent(javaHasAnnotations,org.eclipse.persistence.oxm.annotations.XmlWriteTransformer.class)|| helper.isAnnotationPresent(javaHasAnnotations,XmlWriteTransformers.class)) {
    property=buildTransformationProperty(javaHasAnnotations,cls);
  }
 else {
    property=new Property(helper);
  }
  property.setPropertyName(propertyName);
  property.setElement(javaHasAnnotations);
  if (isCollectionType(ptype)) {
    JavaClass componentType=helper.getJavaClass(Object.class);
    ;
    if (ptype.hasActualTypeArguments()) {
      ArrayList typeArgs=(ArrayList)ptype.getActualTypeArguments();
      if (typeArgs.size() > 0) {
        componentType=(JavaClass)typeArgs.get(0);
      }
    }
    updatePropertyType(property,ptype,componentType);
  }
 else {
    updatePropertyType(property,ptype,ptype);
  }
  if ((ptype.isArray() && !areEquals(ptype,byte[].class)) || (property.isCollectionType(ptype) && !helper.isAnnotationPresent(javaHasAnnotations,XmlList.class))) {
    property.setNillable(true);
  }
  processPropertyAnnotations(info,cls,javaHasAnnotations,property);
  if (helper.isAnnotationPresent(javaHasAnnotations,XmlPath.class)) {
    XmlPath xmlPath=(XmlPath)helper.getAnnotation(javaHasAnnotations,XmlPath.class);
    property.setXmlPath(xmlPath.value());
    XMLField tempField=new XMLField(xmlPath.value());
    boolean isAttribute=tempField.getLastXPathFragment().isAttribute();
    property.setIsAttribute(isAttribute);
    String schemaName=XMLProcessor.getNameFromXPath(xmlPath.value(),property.getPropertyName(),isAttribute);
    QName qName;
    NamespaceInfo nsInfo=getPackageInfoForPackage(cls).getNamespaceInfo();
    if (isAttribute) {
      if (nsInfo.isAttributeFormQualified()) {
        qName=new QName(nsInfo.getNamespace(),schemaName);
      }
 else {
        qName=new QName(schemaName);
      }
    }
 else {
      if (nsInfo.isElementFormQualified()) {
        qName=new QName(nsInfo.getNamespace(),schemaName);
      }
 else {
        qName=new QName(schemaName);
      }
    }
    property.setSchemaName(qName);
    XPathFragment fragment=tempField.getXPathFragment();
    String currentPath="String_Node_Str";
    while (fragment != null && !(fragment.nameIsText()) && !(fragment.isAttribute())) {
      if (fragment.getPredicate() != null) {
        String fragmentPath=fragment.getLocalName();
        if (fragment.getPrefix() != null && !(XMLConstants.EMPTY_STRING.equals(fragment.getPrefix()))) {
          fragmentPath=fragment.getPrefix() + "String_Node_Str" + fragmentPath;
        }
        currentPath+=fragmentPath;
        String predicatePath=currentPath;
        TypeInfo targetInfo=info;
        if (fragment.getNextFragment() == null) {
          TypeInfo predicateTypeInfo=typeInfo.get(ptype.getQualifiedName());
          if (predicateTypeInfo == null && shouldGenerateTypeInfo(ptype)) {
            buildNewTypeInfo(new JavaClass[]{ptype});
            predicateTypeInfo=typeInfo.get(ptype.getQualifiedName());
          }
          if (predicateTypeInfo != null) {
            targetInfo=predicateTypeInfo;
            predicatePath="String_Node_Str";
          }
        }
        Property predicateProperty=new Property(helper);
        predicateProperty.setType(helper.getJavaClass("String_Node_Str"));
        if (predicatePath.length() > 0) {
          predicatePath+="String_Node_Str";
        }
        predicatePath+=fragment.getPredicate().getXPathFragment().getXPath();
        predicateProperty.setXmlPath(predicatePath);
        predicateProperty.setIsAttribute(true);
        String predschemaName=XMLProcessor.getNameFromXPath(predicatePath,property.getPropertyName(),true);
        QName predQname;
        if (nsInfo.isAttributeFormQualified()) {
          predQname=new QName(nsInfo.getNamespace(),predschemaName);
        }
 else {
          predQname=new QName(predschemaName);
        }
        predicateProperty.setSchemaName(predQname);
        if (!targetInfo.hasPredicateProperty(predicateProperty)) {
          targetInfo.getPredicateProperties().add(predicateProperty);
        }
      }
 else {
        currentPath+=fragment.getXPath();
      }
      currentPath+="String_Node_Str";
      fragment=fragment.getNextFragment();
    }
  }
 else {
    property.setSchemaName(getQNameForProperty(propertyName,javaHasAnnotations,getPackageInfoForPackage(cls).getNamespaceInfo(),info));
  }
  ptype=property.getActualType();
  if (ptype.isPrimitive()) {
    property.setIsRequired(true);
  }
  if (!property.isSetXmlJavaTypeAdapter()) {
    TypeInfo refClassInfo=getTypeInfo().get(ptype.getQualifiedName());
    if (refClassInfo != null && refClassInfo.isSetXmlJavaTypeAdapter()) {
      org.eclipse.persistence.jaxb.xmlmodel.XmlJavaTypeAdapter xmlJavaTypeAdapter=null;
      try {
        xmlJavaTypeAdapter=refClassInfo.getXmlJavaTypeAdapter();
        property.setXmlJavaTypeAdapter(refClassInfo.getXmlJavaTypeAdapter());
      }
 catch (      JAXBException e) {
        throw JAXBException.invalidTypeAdapterClass(xmlJavaTypeAdapter.getValue(),cls.getName());
      }
    }
  }
  if (property.isXmlTransformation()) {
    referencedByTransformer.add(property.getType().getName());
  }
  return property;
}

Fixed version (ground truth):
Property buildNewProperty(TypeInfo info,JavaClass cls,JavaHasAnnotations javaHasAnnotations,String propertyName,JavaClass ptype){
  Property property=null;
  if (helper.isAnnotationPresent(javaHasAnnotations,XmlElements.class)) {
    property=buildChoiceProperty(javaHasAnnotations);
  }
 else   if (helper.isAnnotationPresent(javaHasAnnotations,XmlElementRef.class) || helper.isAnnotationPresent(javaHasAnnotations,XmlElementRefs.class)) {
    findAndProcessObjectFactory(cls);
    property=buildReferenceProperty(info,javaHasAnnotations,propertyName,ptype);
    if (helper.isAnnotationPresent(javaHasAnnotations,XmlAnyElement.class)) {
      XmlAnyElement anyElement=(XmlAnyElement)helper.getAnnotation(javaHasAnnotations,XmlAnyElement.class);
      property.setIsAny(true);
      if (anyElement.value() != null) {
        property.setDomHandlerClassName(anyElement.value().getName());
      }
      property.setLax(anyElement.lax());
      info.setAnyElementPropertyName(propertyName);
    }
  }
 else   if (helper.isAnnotationPresent(javaHasAnnotations,XmlAnyElement.class)) {
    findAndProcessObjectFactory(cls);
    XmlAnyElement anyElement=(XmlAnyElement)helper.getAnnotation(javaHasAnnotations,XmlAnyElement.class);
    property=new Property(helper);
    property.setIsAny(true);
    if (anyElement.value() != null) {
      property.setDomHandlerClassName(anyElement.value().getName());
    }
    property.setLax(anyElement.lax());
    info.setAnyElementPropertyName(propertyName);
  }
 else   if (helper.isAnnotationPresent(javaHasAnnotations,org.eclipse.persistence.oxm.annotations.XmlTransformation.class) || helper.isAnnotationPresent(javaHasAnnotations,org.eclipse.persistence.oxm.annotations.XmlReadTransformer.class) || helper.isAnnotationPresent(javaHasAnnotations,org.eclipse.persistence.oxm.annotations.XmlWriteTransformer.class)|| helper.isAnnotationPresent(javaHasAnnotations,XmlWriteTransformers.class)) {
    property=buildTransformationProperty(javaHasAnnotations,cls);
  }
 else {
    property=new Property(helper);
  }
  property.setPropertyName(propertyName);
  property.setElement(javaHasAnnotations);
  if (isCollectionType(ptype)) {
    JavaClass componentType=helper.getJavaClass(Object.class);
    ;
    Collection typeArgs=ptype.getActualTypeArguments();
    if (typeArgs.size() > 0) {
      componentType=(JavaClass)typeArgs.iterator().next();
    }
    updatePropertyType(property,ptype,componentType);
  }
 else {
    updatePropertyType(property,ptype,ptype);
  }
  if ((ptype.isArray() && !areEquals(ptype,byte[].class)) || (property.isCollectionType(ptype) && !helper.isAnnotationPresent(javaHasAnnotations,XmlList.class))) {
    property.setNillable(true);
  }
  processPropertyAnnotations(info,cls,javaHasAnnotations,property);
  if (helper.isAnnotationPresent(javaHasAnnotations,XmlPath.class)) {
    XmlPath xmlPath=(XmlPath)helper.getAnnotation(javaHasAnnotations,XmlPath.class);
    property.setXmlPath(xmlPath.value());
    XMLField tempField=new XMLField(xmlPath.value());
    boolean isAttribute=tempField.getLastXPathFragment().isAttribute();
    property.setIsAttribute(isAttribute);
    String schemaName=XMLProcessor.getNameFromXPath(xmlPath.value(),property.getPropertyName(),isAttribute);
    QName qName;
    NamespaceInfo nsInfo=getPackageInfoForPackage(cls).getNamespaceInfo();
    if (isAttribute) {
      if (nsInfo.isAttributeFormQualified()) {
        qName=new QName(nsInfo.getNamespace(),schemaName);
      }
 else {
        qName=new QName(schemaName);
      }
    }
 else {
      if (nsInfo.isElementFormQualified()) {
        qName=new QName(nsInfo.getNamespace(),schemaName);
      }
 else {
        qName=new QName(schemaName);
      }
    }
    property.setSchemaName(qName);
    XPathFragment fragment=tempField.getXPathFragment();
    String currentPath="String_Node_Str";
    while (fragment != null && !(fragment.nameIsText()) && !(fragment.isAttribute())) {
      if (fragment.getPredicate() != null) {
        String fragmentPath=fragment.getLocalName();
        if (fragment.getPrefix() != null && !(XMLConstants.EMPTY_STRING.equals(fragment.getPrefix()))) {
          fragmentPath=fragment.getPrefix() + "String_Node_Str" + fragmentPath;
        }
        currentPath+=fragmentPath;
        String predicatePath=currentPath;
        TypeInfo targetInfo=info;
        if (fragment.getNextFragment() == null) {
          TypeInfo predicateTypeInfo=typeInfo.get(ptype.getQualifiedName());
          if (predicateTypeInfo == null && shouldGenerateTypeInfo(ptype)) {
            buildNewTypeInfo(new JavaClass[]{ptype});
            predicateTypeInfo=typeInfo.get(ptype.getQualifiedName());
          }
          if (predicateTypeInfo != null) {
            targetInfo=predicateTypeInfo;
            predicatePath="String_Node_Str";
          }
        }
        Property predicateProperty=new Property(helper);
        predicateProperty.setType(helper.getJavaClass("String_Node_Str"));
        if (predicatePath.length() > 0) {
          predicatePath+="String_Node_Str";
        }
        predicatePath+=fragment.getPredicate().getXPathFragment().getXPath();
        predicateProperty.setXmlPath(predicatePath);
        predicateProperty.setIsAttribute(true);
        String predschemaName=XMLProcessor.getNameFromXPath(predicatePath,property.getPropertyName(),true);
        QName predQname;
        if (nsInfo.isAttributeFormQualified()) {
          predQname=new QName(nsInfo.getNamespace(),predschemaName);
        }
 else {
          predQname=new QName(predschemaName);
        }
        predicateProperty.setSchemaName(predQname);
        if (!targetInfo.hasPredicateProperty(predicateProperty)) {
          targetInfo.getPredicateProperties().add(predicateProperty);
        }
      }
 else {
        currentPath+=fragment.getXPath();
      }
      currentPath+="String_Node_Str";
      fragment=fragment.getNextFragment();
    }
  }
 else {
    property.setSchemaName(getQNameForProperty(propertyName,javaHasAnnotations,getPackageInfoForPackage(cls).getNamespaceInfo(),info));
  }
  ptype=property.getActualType();
  if (ptype.isPrimitive()) {
    property.setIsRequired(true);
  }
  if (!property.isSetXmlJavaTypeAdapter()) {
    TypeInfo refClassInfo=getTypeInfo().get(ptype.getQualifiedName());
    if (refClassInfo != null && refClassInfo.isSetXmlJavaTypeAdapter()) {
      org.eclipse.persistence.jaxb.xmlmodel.XmlJavaTypeAdapter xmlJavaTypeAdapter=null;
      try {
        xmlJavaTypeAdapter=refClassInfo.getXmlJavaTypeAdapter();
        property.setXmlJavaTypeAdapter(refClassInfo.getXmlJavaTypeAdapter());
      }
 catch (      JAXBException e) {
        throw JAXBException.invalidTypeAdapterClass(xmlJavaTypeAdapter.getValue(),cls.getName());
      }
    }
  }
  if (property.isXmlTransformation()) {
    referencedByTransformer.add(property.getType().getName());
  }
  return property;
}