Program: 67718
Project: 67718
Buggy source:
public XMLMapping generateMappingForReferenceProperty(ReferenceProperty property,XMLDescriptor descriptor,NamespaceInfo namespaceInfo){
  DatabaseMapping mapping;
  boolean isCollection=isCollectionType(property);
  if (isCollection) {
    mapping=new XMLChoiceCollectionMapping();
  }
 else {
    mapping=new XMLChoiceObjectMapping();
  }
  mapping.setAttributeName(property.getPropertyName());
  if (property.isMethodProperty()) {
    mapping.setGetMethodName(property.getGetMethodName());
    mapping.setSetMethodName(property.getSetMethodName());
  }
  List<ElementDeclaration> referencedElements=property.getReferencedElements();
  boolean hasJAXBElements=false;
  AttributeAccessor mappingAccessor=mapping.getAttributeAccessor();
  for (  ElementDeclaration element : referencedElements) {
    QName elementName=element.getElementName();
    XMLField xmlField=this.getXPathForElement("String_Node_Str",elementName,namespaceInfo,!(this.typeInfo.containsKey(element.getJavaTypeName())));
    if (isCollection) {
      ((XMLChoiceCollectionMapping)mapping).addChoiceElement(xmlField,element.getJavaTypeName());
    }
 else {
      ((XMLChoiceObjectMapping)mapping).addChoiceElement(xmlField,element.getJavaTypeName());
    }
    if (!element.isXmlRootElement()) {
      XMLRootConverter converter=new XMLRootConverter(xmlField);
      if (isCollection) {
        ((XMLChoiceCollectionMapping)mapping).addConverter(xmlField,converter);
      }
 else {
        ((XMLChoiceObjectMapping)mapping).addConverter(xmlField,converter);
      }
    }
    hasJAXBElements=hasJAXBElements || !element.isXmlRootElement();
    if (hasJAXBElements) {
      mapping.setAttributeAccessor(new JAXBElementAttributeAccessor(mappingAccessor));
    }
  }
  descriptor.addMapping(mapping);
  return (XMLMapping)mapping;
}

Fixed version (ground truth):
public XMLMapping generateMappingForReferenceProperty(ReferenceProperty property,XMLDescriptor descriptor,NamespaceInfo namespaceInfo){
  DatabaseMapping mapping;
  boolean isCollection=isCollectionType(property);
  if (isCollection) {
    mapping=new XMLChoiceCollectionMapping();
  }
 else {
    mapping=new XMLChoiceObjectMapping();
  }
  mapping.setAttributeName(property.getPropertyName());
  if (property.isMethodProperty()) {
    mapping.setGetMethodName(property.getGetMethodName());
    mapping.setSetMethodName(property.getSetMethodName());
  }
  List<ElementDeclaration> referencedElements=property.getReferencedElements();
  boolean hasJAXBElements=false;
  AttributeAccessor mappingAccessor=mapping.getAttributeAccessor();
  Map<QName,Class> qNamesToScopeClass=new HashMap<QName,Class>();
  for (  ElementDeclaration element : referencedElements) {
    QName elementName=element.getElementName();
    XMLField xmlField=this.getXPathForElement("String_Node_Str",elementName,namespaceInfo,!(this.typeInfo.containsKey(element.getJavaTypeName())));
    if (isCollection) {
      ((XMLChoiceCollectionMapping)mapping).addChoiceElement(xmlField,element.getJavaTypeName());
    }
 else {
      ((XMLChoiceObjectMapping)mapping).addChoiceElement(xmlField,element.getJavaTypeName());
    }
    if (!element.isXmlRootElement()) {
      XMLRootConverter converter=new XMLRootConverter(xmlField);
      if (isCollection) {
        ((XMLChoiceCollectionMapping)mapping).addConverter(xmlField,converter);
      }
 else {
        ((XMLChoiceObjectMapping)mapping).addConverter(xmlField,converter);
      }
      qNamesToScopeClass.put(elementName,element.getScopeClass());
    }
    hasJAXBElements=hasJAXBElements || !element.isXmlRootElement();
  }
  if (hasJAXBElements) {
    JAXBElementAttributeAccessor accessor=new JAXBElementAttributeAccessor(mappingAccessor);
    accessor.setQNamesToScopes(qNamesToScopeClass);
    mapping.setAttributeAccessor(accessor);
  }
  descriptor.addMapping(mapping);
  return (XMLMapping)mapping;
}