Program: 67239
Project: 67239
Buggy source:
public XMLMapping generateMappingForReferenceProperty(ReferenceProperty property,XMLDescriptor descriptor,NamespaceInfo namespaceInfo){
  boolean isCollection=isCollectionType(property);
  DatabaseMapping mapping;
  if (isCollection) {
    mapping=new XMLChoiceCollectionMapping();
  }
 else {
    mapping=new XMLChoiceObjectMapping();
  }
  mapping.setAttributeName(property.getPropertyName());
  if (property.isMethodProperty()) {
    if (property.getGetMethodName() == null) {
      String paramTypeAsString=property.getType().getName();
      mapping.setAttributeAccessor(new JAXBSetMethodAttributeAccessor(paramTypeAsString,helper.getClassLoader()));
      mapping.setIsReadOnly(true);
      mapping.setSetMethodName(property.getSetMethodName());
    }
 else     if (property.getSetMethodName() == null) {
      mapping.setGetMethodName(property.getGetMethodName());
      ((XMLMapping)mapping).setIsWriteOnly(true);
    }
 else {
      mapping.setSetMethodName(property.getSetMethodName());
      mapping.setGetMethodName(property.getGetMethodName());
    }
  }
  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();
    boolean isText=!(this.typeInfo.containsKey(element.getJavaTypeName())) && !(element.getJavaTypeName().equals(OBJECT_CLASS_NAME));
    XMLField xmlField=this.getXPathForElement("String_Node_Str",elementName,namespaceInfo,isText);
    if (helper.getXMLToJavaTypeMap().get(element.getJavaType().getRawName()) == XMLConstants.BASE_64_BINARY_QNAME) {
      xmlField.setSchemaType(XMLConstants.BASE_64_BINARY_QNAME);
    }
    if (isCollection) {
      ((XMLChoiceCollectionMapping)mapping).addChoiceElement(xmlField,element.getJavaTypeName());
      XMLMapping nestedMapping=((XMLChoiceCollectionMapping)mapping).getChoiceElementMappings().get(xmlField);
      if (((DatabaseMapping)nestedMapping).isAbstractCompositeCollectionMapping()) {
        ((XMLCompositeCollectionMapping)nestedMapping).setKeepAsElementPolicy(UnmarshalKeepAsElementPolicy.KEEP_UNKNOWN_AS_ELEMENT);
      }
      if (element.isList() && ((DatabaseMapping)nestedMapping).isAbstractCompositeDirectCollectionMapping()) {
        XMLListConverter listConverter=new XMLListConverter();
        listConverter.setObjectClassName(element.getJavaType().getQualifiedName());
        ((XMLCompositeDirectCollectionMapping)nestedMapping).setValueConverter(listConverter);
      }
    }
 else {
      ((XMLChoiceObjectMapping)mapping).addChoiceElement(xmlField,element.getJavaTypeName());
      XMLMapping nestedMapping=((XMLChoiceObjectMapping)mapping).getChoiceElementMappings().get(xmlField);
      if (((DatabaseMapping)nestedMapping).isAbstractCompositeObjectMapping()) {
        ((XMLCompositeObjectMapping)nestedMapping).setKeepAsElementPolicy(UnmarshalKeepAsElementPolicy.KEEP_UNKNOWN_AS_ELEMENT);
      }
    }
    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;
    if (isCollection) {
      accessor=new JAXBElementAttributeAccessor(mappingAccessor,mapping.getContainerPolicy());
    }
 else {
      accessor=new JAXBElementAttributeAccessor(mappingAccessor);
    }
    accessor.setQNamesToScopes(qNamesToScopeClass);
    mapping.setAttributeAccessor(accessor);
  }
  descriptor.addMapping(mapping);
  return (XMLMapping)mapping;
}

Fixed version (ground truth):
public XMLMapping generateMappingForReferenceProperty(ReferenceProperty property,XMLDescriptor descriptor,NamespaceInfo namespaceInfo){
  boolean isCollection=isCollectionType(property);
  DatabaseMapping mapping;
  if (isCollection) {
    mapping=new XMLChoiceCollectionMapping();
  }
 else {
    mapping=new XMLChoiceObjectMapping();
  }
  mapping.setAttributeName(property.getPropertyName());
  if (property.isMethodProperty()) {
    if (property.getGetMethodName() == null) {
      String paramTypeAsString=property.getType().getName();
      mapping.setAttributeAccessor(new JAXBSetMethodAttributeAccessor(paramTypeAsString,helper.getClassLoader()));
      mapping.setIsReadOnly(true);
      mapping.setSetMethodName(property.getSetMethodName());
    }
 else     if (property.getSetMethodName() == null) {
      mapping.setGetMethodName(property.getGetMethodName());
      ((XMLMapping)mapping).setIsWriteOnly(true);
    }
 else {
      mapping.setSetMethodName(property.getSetMethodName());
      mapping.setGetMethodName(property.getGetMethodName());
    }
  }
  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();
    boolean isText=!(this.typeInfo.containsKey(element.getJavaTypeName())) && !(element.getJavaTypeName().equals(OBJECT_CLASS_NAME));
    XMLField xmlField=this.getXPathForElement("String_Node_Str",elementName,namespaceInfo,isText);
    if (helper.getXMLToJavaTypeMap().get(element.getJavaType().getRawName()) == XMLConstants.BASE_64_BINARY_QNAME) {
      xmlField.setSchemaType(XMLConstants.BASE_64_BINARY_QNAME);
    }
    if (isCollection) {
      ((XMLChoiceCollectionMapping)mapping).addChoiceElement(xmlField,element.getJavaTypeName());
      XMLMapping nestedMapping=((XMLChoiceCollectionMapping)mapping).getChoiceElementMappings().get(xmlField);
      if (((DatabaseMapping)nestedMapping).isAbstractCompositeCollectionMapping()) {
        ((XMLCompositeCollectionMapping)nestedMapping).setKeepAsElementPolicy(UnmarshalKeepAsElementPolicy.KEEP_UNKNOWN_AS_ELEMENT);
      }
      if (((DatabaseMapping)nestedMapping).isAbstractCompositeDirectCollectionMapping()) {
        ((XMLCompositeDirectCollectionMapping)nestedMapping).getNullPolicy().setNullRepresentedByEmptyNode(false);
      }
      if (element.isList() && ((DatabaseMapping)nestedMapping).isAbstractCompositeDirectCollectionMapping()) {
        XMLListConverter listConverter=new XMLListConverter();
        listConverter.setObjectClassName(element.getJavaType().getQualifiedName());
        ((XMLCompositeDirectCollectionMapping)nestedMapping).setValueConverter(listConverter);
      }
    }
 else {
      ((XMLChoiceObjectMapping)mapping).addChoiceElement(xmlField,element.getJavaTypeName());
      XMLMapping nestedMapping=((XMLChoiceObjectMapping)mapping).getChoiceElementMappings().get(xmlField);
      if (((DatabaseMapping)nestedMapping).isAbstractCompositeObjectMapping()) {
        ((XMLCompositeObjectMapping)nestedMapping).setKeepAsElementPolicy(UnmarshalKeepAsElementPolicy.KEEP_UNKNOWN_AS_ELEMENT);
      }
    }
    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;
    if (isCollection) {
      accessor=new JAXBElementAttributeAccessor(mappingAccessor,mapping.getContainerPolicy());
    }
 else {
      accessor=new JAXBElementAttributeAccessor(mappingAccessor);
    }
    accessor.setQNamesToScopes(qNamesToScopeClass);
    mapping.setAttributeAccessor(accessor);
  }
  descriptor.addMapping(mapping);
  return (XMLMapping)mapping;
}