Program: 66831
Project: 66831
Buggy source:
/** 
 * Create an XMLCollectionReferenceMapping and add it to the descriptor.
 * @param property
 * @param descriptor
 * @param namespaceInfo
 * @param referenceClass
 */
public void generateXMLCollectionReferenceMapping(Property property,XMLDescriptor descriptor,NamespaceInfo namespaceInfo,JavaClass referenceClass){
  XMLField srcXPath=getXPathForField(property,namespaceInfo,true);
  XMLCollectionReferenceMapping mapping=new XMLCollectionReferenceMapping();
  mapping.setAttributeName(property.getPropertyName());
  mapping.setReuseContainer(true);
  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());
      mapping.setIsWriteOnly(true);
    }
 else {
      mapping.setSetMethodName(property.getSetMethodName());
      mapping.setGetMethodName(property.getGetMethodName());
    }
  }
  mapping.setReferenceClassName(referenceClass.getQualifiedName());
  JavaClass collectionType=property.getType();
  if (areEquals(collectionType,Collection.class) || areEquals(collectionType,List.class)) {
    collectionType=jotArrayList;
  }
 else   if (areEquals(collectionType,Set.class)) {
    collectionType=jotHashSet;
  }
  mapping.useCollectionClassName(collectionType.getRawName());
  TypeInfo referenceType=typeInfo.get(referenceClass.getQualifiedName());
  if (referenceType.isIDSet()) {
    Property prop=referenceType.getIDProperty();
    XMLField tgtXPath=getXPathForField(prop,namespaceInfo,!(helper.isAnnotationPresent(prop.getElement(),XmlAttribute.class)));
    mapping.addSourceToTargetKeyFieldAssociation(srcXPath.getXPath(),tgtXPath.getXPath());
  }
  if (property.getBackpointerPropertyName() != null) {
    mapping.setBidirectionalTargetAttributeName(property.getBackpointerPropertyName());
    JavaClass backPointerPropertyType=null;
    if (property.getBackpointerGetMethodName() != null && property.getBackpointerSetMethodName() != null && !property.getBackpointerGetMethodName().equals("String_Node_Str") && !property.getBackpointerSetMethodName().equals("String_Node_Str")) {
      mapping.setBidirectionalTargetGetMethodName(property.getBackpointerSetMethodName());
      mapping.setBidirectionalTargetSetMethodName(property.getBackpointerSetMethodName());
      JavaMethod getMethod=referenceClass.getDeclaredMethod(mapping.getBidirectionalTargetGetMethodName(),new JavaClass[]{});
      if (getMethod != null) {
        backPointerPropertyType=getMethod.getReturnType();
      }
    }
 else {
      JavaField backpointerField=referenceClass.getDeclaredField(property.getBackpointerPropertyName());
      if (backpointerField != null) {
        backPointerPropertyType=backpointerField.getResolvedType();
      }
    }
    if (isCollectionType(backPointerPropertyType)) {
      mapping.setBidirectionalTargetContainerPolicy(ContainerPolicy.buildDefaultPolicy());
    }
  }
  descriptor.addMapping(mapping);
}

Fixed version (ground truth):
/** 
 * Create an XMLCollectionReferenceMapping and add it to the descriptor.
 * @param property
 * @param descriptor
 * @param namespaceInfo
 * @param referenceClass
 */
public void generateXMLCollectionReferenceMapping(Property property,XMLDescriptor descriptor,NamespaceInfo namespaceInfo,JavaClass referenceClass){
  XMLField srcXPath=getXPathForField(property,namespaceInfo,true);
  XMLCollectionReferenceMapping mapping=new XMLCollectionReferenceMapping();
  mapping.setAttributeName(property.getPropertyName());
  mapping.setReuseContainer(true);
  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());
      mapping.setIsWriteOnly(true);
    }
 else {
      mapping.setSetMethodName(property.getSetMethodName());
      mapping.setGetMethodName(property.getGetMethodName());
    }
  }
  mapping.setReferenceClassName(referenceClass.getQualifiedName());
  JavaClass collectionType=property.getType();
  if (areEquals(collectionType,Collection.class) || areEquals(collectionType,List.class)) {
    collectionType=jotArrayList;
  }
 else   if (areEquals(collectionType,Set.class)) {
    collectionType=jotHashSet;
  }
  mapping.useCollectionClassName(collectionType.getRawName());
  TypeInfo referenceType=typeInfo.get(referenceClass.getQualifiedName());
  if (referenceType.isIDSet()) {
    Property prop=referenceType.getIDProperty();
    XMLField tgtXPath=getXPathForField(prop,namespaceInfo,!(helper.isAnnotationPresent(prop.getElement(),XmlAttribute.class)));
    mapping.addSourceToTargetKeyFieldAssociation(srcXPath.getXPath(),tgtXPath.getXPath());
  }
  if (property.getBidirectionalPropertyName() != null) {
    mapping.setBidirectionalTargetAttributeName(property.getBidirectionalPropertyName());
    JavaClass backPointerPropertyType=null;
    if (property.getBidirectionalPropertyGetMethodName() != null && property.getBidirectionalPropertySetMethodName() != null && !property.getBidirectionalPropertyGetMethodName().equals("String_Node_Str") && !property.getBidirectionalPropertySetMethodName().equals("String_Node_Str")) {
      mapping.setBidirectionalTargetGetMethodName(property.getBidirectionalPropertySetMethodName());
      mapping.setBidirectionalTargetSetMethodName(property.getBidirectionalPropertySetMethodName());
      JavaMethod getMethod=referenceClass.getDeclaredMethod(mapping.getBidirectionalTargetGetMethodName(),new JavaClass[]{});
      if (getMethod != null) {
        backPointerPropertyType=getMethod.getReturnType();
      }
    }
 else {
      JavaField backpointerField=referenceClass.getDeclaredField(property.getBidirectionalPropertyName());
      if (backpointerField != null) {
        backPointerPropertyType=backpointerField.getResolvedType();
      }
    }
    if (isCollectionType(backPointerPropertyType)) {
      mapping.setBidirectionalTargetContainerPolicy(ContainerPolicy.buildDefaultPolicy());
    }
  }
  descriptor.addMapping(mapping);
}