Program: 63647
Project: 63647
Buggy source:
/** 
 * Complete creation of a 'choice' property. Here, a Property is created for each XmlElement in the XmlElements list. Validation is performed as well. Each created Property is added to the owning Property's list of choice properties.
 * @param choiceProperty
 * @param info
 * @param cls
 * @param propertyType
 */
private void processChoiceProperty(Property choiceProperty,TypeInfo info,JavaClass cls,JavaClass propertyType){
  String propertyName=choiceProperty.getPropertyName();
  if (choiceProperty.isSetXmlJoinNodesList()) {
    if (choiceProperty.getXmlElements().getXmlElement().size() != choiceProperty.getXmlJoinNodesList().size()) {
      throw JAXBException.incorrectNumberOfXmlJoinNodesOnXmlElements(propertyName,cls.getQualifiedName());
    }
  }
  XmlPath[] paths=null;
  if (helper.isAnnotationPresent(choiceProperty.getElement(),XmlPaths.class)) {
    XmlPaths pathAnnotation=(XmlPaths)helper.getAnnotation(choiceProperty.getElement(),XmlPaths.class);
    paths=pathAnnotation.value();
  }
  ArrayList<Property> choiceProperties=new ArrayList<Property>();
  for (int i=0; i < choiceProperty.getXmlElements().getXmlElement().size(); i++) {
    org.eclipse.persistence.jaxb.xmlmodel.XmlElement next=choiceProperty.getXmlElements().getXmlElement().get(i);
    Property choiceProp=new Property(helper);
    String name;
    String namespace;
    choiceProp.setNillable(next.isNillable());
    choiceProp.setIsRequired(next.isRequired());
    if (paths != null && next.getXmlPath() == null) {
      XmlPath nextPath=paths[i];
      next.setXmlPath(nextPath.value());
    }
    if (next.getXmlPath() != null) {
      choiceProp.setXmlPath(next.getXmlPath());
      boolean isAttribute=new XMLField(next.getXmlPath()).getLastXPathFragment().isAttribute();
      if (isAttribute && !next.getXmlPath().contains(SLASH)) {
        throw JAXBException.invalidXmlPathWithAttribute(propertyName,cls.getQualifiedName(),next.getXmlPath());
      }
      choiceProp.setIsAttribute(isAttribute);
      name=XMLProcessor.getNameFromXPath(next.getXmlPath(),propertyName,isAttribute);
      namespace=XMLProcessor.DEFAULT;
    }
 else {
      name=next.getName();
      namespace=next.getNamespace();
    }
    if (name == null || name.equals(XMLProcessor.DEFAULT)) {
      if (next.getJavaAttribute() != null) {
        name=next.getJavaAttribute();
      }
 else {
        name=propertyName;
      }
    }
    if (choiceProperty.isXmlIdRef()) {
      TypeInfo tInfo=typeInfo.get(next.getType());
      if (tInfo == null) {
        JavaClass nextCls=helper.getJavaClass(next.getType());
        if (shouldGenerateTypeInfo(nextCls)) {
          buildNewTypeInfo(new JavaClass[]{nextCls});
          tInfo=typeInfo.get(next.getType());
        }
      }
      if (tInfo == null || !tInfo.isIDSet()) {
        throw JAXBException.invalidXmlElementInXmlElementsList(propertyName,name);
      }
    }
    QName qName=null;
    if (!namespace.equals(XMLProcessor.DEFAULT)) {
      qName=new QName(namespace,name);
    }
 else {
      NamespaceInfo namespaceInfo=getPackageInfoForPackage(cls).getNamespaceInfo();
      if (namespaceInfo.isElementFormQualified()) {
        qName=new QName(namespaceInfo.getNamespace(),name);
      }
 else {
        qName=new QName(name);
      }
    }
    choiceProp.setPropertyName(name);
    if (next.getType().equals("String_Node_Str") || next.getType().equals("String_Node_Str")) {
      choiceProp.setType(propertyType);
    }
 else {
      choiceProp.setType(helper.getJavaClass(next.getType()));
    }
    if (choiceProperty.isSetXmlJoinNodesList()) {
      org.eclipse.persistence.jaxb.xmlmodel.XmlJoinNodes xmlJoinNodes=choiceProperty.getXmlJoinNodesList().get(i);
      if (xmlJoinNodes != null) {
        choiceProp.setXmlJoinNodes(xmlJoinNodes);
        if (!xmlJoinNodes.getType().equals(XMLProcessor.DEFAULT)) {
          JavaClass pType=helper.getJavaClass(xmlJoinNodes.getType());
          if (helper.isCollectionType(choiceProp.getType())) {
            choiceProp.setGenericType(pType);
          }
 else {
            choiceProp.setType(pType);
          }
        }
      }
    }
    choiceProp.setSchemaName(qName);
    choiceProp.setSchemaType(getSchemaTypeFor(choiceProp.getType()));
    choiceProp.setIsXmlIdRef(choiceProperty.isXmlIdRef());
    choiceProp.setXmlElementWrapper(choiceProperty.getXmlElementWrapper());
    choiceProperties.add(choiceProp);
    if (!(this.typeInfo.containsKey(choiceProp.getType().getQualifiedName())) && shouldGenerateTypeInfo(choiceProp.getType())) {
      JavaClass[] jClassArray=new JavaClass[]{choiceProp.getType()};
      buildNewTypeInfo(jClassArray);
      TypeInfo newInfo=typeInfo.get(choiceProp.getType().getQualifiedName());
      if (newInfo != null && newInfo.isTransient()) {
        throw JAXBException.invalidReferenceToTransientClass(info.getJavaClassName(),choiceProperty.getPropertyName(),newInfo.getJavaClassName());
      }
    }
  }
  choiceProperty.setChoiceProperties(choiceProperties);
}

Fixed version (ground truth):
/** 
 * Complete creation of a 'choice' property. Here, a Property is created for each XmlElement in the XmlElements list. Validation is performed as well. Each created Property is added to the owning Property's list of choice properties.
 * @param choiceProperty
 * @param info
 * @param cls
 * @param propertyType
 */
private void processChoiceProperty(Property choiceProperty,TypeInfo info,JavaClass cls,JavaClass propertyType){
  String propertyName=choiceProperty.getPropertyName();
  if (choiceProperty.isSetXmlJoinNodesList()) {
    if (choiceProperty.getXmlElements().getXmlElement().size() != choiceProperty.getXmlJoinNodesList().size()) {
      throw JAXBException.incorrectNumberOfXmlJoinNodesOnXmlElements(propertyName,cls.getQualifiedName());
    }
  }
  XmlPath[] paths=null;
  if (helper.isAnnotationPresent(choiceProperty.getElement(),XmlPaths.class)) {
    XmlPaths pathAnnotation=(XmlPaths)helper.getAnnotation(choiceProperty.getElement(),XmlPaths.class);
    paths=pathAnnotation.value();
  }
  ArrayList<Property> choiceProperties=new ArrayList<Property>();
  for (int i=0; i < choiceProperty.getXmlElements().getXmlElement().size(); i++) {
    org.eclipse.persistence.jaxb.xmlmodel.XmlElement next=choiceProperty.getXmlElements().getXmlElement().get(i);
    Property choiceProp=new Property(helper);
    String name;
    String namespace;
    choiceProp.setNillable(next.isNillable());
    choiceProp.setIsRequired(next.isRequired());
    if (paths != null && next.getXmlPath() == null) {
      XmlPath nextPath=paths[i];
      next.setXmlPath(nextPath.value());
    }
    if (next.getXmlPath() != null) {
      choiceProp.setXmlPath(next.getXmlPath());
      boolean isAttribute=new XMLField(next.getXmlPath()).getLastXPathFragment().isAttribute();
      if (isAttribute && !next.getXmlPath().contains(SLASH)) {
        throw JAXBException.invalidXmlPathWithAttribute(propertyName,cls.getQualifiedName(),next.getXmlPath());
      }
      choiceProp.setIsAttribute(isAttribute);
      name=XMLProcessor.getNameFromXPath(next.getXmlPath(),propertyName,isAttribute);
      namespace=XMLProcessor.DEFAULT;
    }
 else {
      name=next.getName();
      namespace=next.getNamespace();
    }
    if (name == null || name.equals(XMLProcessor.DEFAULT)) {
      if (next.getJavaAttribute() != null) {
        name=next.getJavaAttribute();
      }
 else {
        name=propertyName;
      }
    }
    if (choiceProperty.isXmlIdRef()) {
      TypeInfo tInfo=typeInfo.get(next.getType());
      if (tInfo == null) {
        JavaClass nextCls=helper.getJavaClass(next.getType());
        if (shouldGenerateTypeInfo(nextCls) && typeInfo.get(nextCls.getQualifiedName()) == null) {
          buildNewTypeInfo(new JavaClass[]{nextCls});
          tInfo=typeInfo.get(next.getType());
        }
      }
      if (tInfo == null || !tInfo.isIDSet()) {
        throw JAXBException.invalidXmlElementInXmlElementsList(propertyName,name);
      }
    }
    QName qName=null;
    if (!namespace.equals(XMLProcessor.DEFAULT)) {
      qName=new QName(namespace,name);
    }
 else {
      NamespaceInfo namespaceInfo=getPackageInfoForPackage(cls).getNamespaceInfo();
      if (namespaceInfo.isElementFormQualified()) {
        qName=new QName(namespaceInfo.getNamespace(),name);
      }
 else {
        qName=new QName(name);
      }
    }
    choiceProp.setPropertyName(name);
    if (next.getType().equals("String_Node_Str") || next.getType().equals("String_Node_Str")) {
      choiceProp.setType(propertyType);
    }
 else {
      choiceProp.setType(helper.getJavaClass(next.getType()));
    }
    if (choiceProperty.isSetXmlJoinNodesList()) {
      org.eclipse.persistence.jaxb.xmlmodel.XmlJoinNodes xmlJoinNodes=choiceProperty.getXmlJoinNodesList().get(i);
      if (xmlJoinNodes != null) {
        choiceProp.setXmlJoinNodes(xmlJoinNodes);
        if (!xmlJoinNodes.getType().equals(XMLProcessor.DEFAULT)) {
          JavaClass pType=helper.getJavaClass(xmlJoinNodes.getType());
          if (helper.isCollectionType(choiceProp.getType())) {
            choiceProp.setGenericType(pType);
          }
 else {
            choiceProp.setType(pType);
          }
        }
      }
    }
    choiceProp.setSchemaName(qName);
    choiceProp.setSchemaType(getSchemaTypeFor(choiceProp.getType()));
    choiceProp.setIsXmlIdRef(choiceProperty.isXmlIdRef());
    choiceProp.setXmlElementWrapper(choiceProperty.getXmlElementWrapper());
    choiceProperties.add(choiceProp);
    if (!(this.typeInfo.containsKey(choiceProp.getType().getQualifiedName())) && shouldGenerateTypeInfo(choiceProp.getType())) {
      JavaClass[] jClassArray=new JavaClass[]{choiceProp.getType()};
      buildNewTypeInfo(jClassArray);
      TypeInfo newInfo=typeInfo.get(choiceProp.getType().getQualifiedName());
      if (newInfo != null && newInfo.isTransient()) {
        throw JAXBException.invalidReferenceToTransientClass(info.getJavaClassName(),choiceProperty.getPropertyName(),newInfo.getJavaClassName());
      }
    }
  }
  choiceProperty.setChoiceProperties(choiceProperties);
}