Program: 64129
Project: 64129
Buggy source:
/** 
 * Build an XMLChoiceObjectMapping based on a particular mapping and replace that mapping with the newly created XMLChoiceObjectMapping in jaxbDescriptor.
 * @param jaxbDescriptor the jaxb descriptor
 * @param jpaMapping the jpa mapping
 * @param cl the classloader
 */
private static void convertMappingToXMLChoiceMapping(ClassDescriptor jaxbDescriptor,DatabaseMapping jpaMapping,ClassLoader cl){
  if ((jpaMapping != null) && (jaxbDescriptor != null)) {
    String attributeName=jpaMapping.getAttributeName();
    DatabaseMapping jaxbMapping=jaxbDescriptor.getMappingForAttributeName(jpaMapping.getAttributeName());
    if (!(jaxbMapping.isXMLMapping() && (jaxbMapping.isAbstractCompositeCollectionMapping() || jaxbMapping.isAbstractCompositeObjectMapping()))) {
      return;
    }
    String adapterClassName=RestAdapterClassWriter.constructClassNameForReferenceAdapter(jpaMapping.getReferenceDescriptor().getJavaClassName());
    try {
      if (jaxbMapping.isAbstractCompositeObjectMapping()) {
        XMLChoiceObjectMapping xmlChoiceMapping=new XMLChoiceObjectMapping();
        xmlChoiceMapping.setAttributeName(attributeName);
        copyAccessorToMapping(jaxbMapping,xmlChoiceMapping);
        xmlChoiceMapping.setProperties(jaxbMapping.getProperties());
        xmlChoiceMapping.addChoiceElement(attributeName,Link.class);
        xmlChoiceMapping.addChoiceElement(attributeName,jpaMapping.getReferenceDescriptor().getJavaClass());
        xmlChoiceMapping.setConverter(new XMLJavaTypeConverter(Class.forName(adapterClassName,true,cl)));
        jaxbDescriptor.removeMappingForAttributeName(jaxbMapping.getAttributeName());
        jaxbDescriptor.addMapping(xmlChoiceMapping);
      }
 else       if (jaxbMapping.isAbstractCompositeCollectionMapping()) {
        XMLChoiceCollectionMapping xmlChoiceMapping=new XMLChoiceCollectionMapping();
        xmlChoiceMapping.setAttributeName(attributeName);
        copyAccessorToMapping(jaxbMapping,xmlChoiceMapping);
        xmlChoiceMapping.setProperties(jaxbMapping.getProperties());
        xmlChoiceMapping.addChoiceElement(attributeName,Link.class);
        xmlChoiceMapping.addChoiceElement(attributeName,jpaMapping.getReferenceDescriptor().getJavaClass());
        xmlChoiceMapping.setConverter(new XMLJavaTypeConverter(Class.forName(adapterClassName,true,cl)));
        jaxbDescriptor.removeMappingForAttributeName(jaxbMapping.getAttributeName());
        jaxbDescriptor.addMapping(xmlChoiceMapping);
      }
    }
 catch (    ClassNotFoundException e) {
      throw new JPARSException(e.toString());
    }
  }
}

Fixed version (ground truth):
/** 
 * Build an XMLChoiceObjectMapping based on a particular mapping and replace that mapping with the newly created XMLChoiceObjectMapping in jaxbDescriptor.
 * @param jaxbDescriptor the jaxb descriptor
 * @param jpaMapping the jpa mapping
 * @param cl the classloader
 */
private static void convertMappingToXMLChoiceMapping(ClassDescriptor jaxbDescriptor,DatabaseMapping jpaMapping,ClassLoader cl){
  if ((jpaMapping != null) && (jaxbDescriptor != null)) {
    if ((jpaMapping.isAggregateCollectionMapping()) || (jpaMapping.isAggregateMapping())) {
      return;
    }
    String attributeName=jpaMapping.getAttributeName();
    DatabaseMapping jaxbMapping=jaxbDescriptor.getMappingForAttributeName(jpaMapping.getAttributeName());
    if (!(jaxbMapping.isXMLMapping() && (jaxbMapping.isAbstractCompositeCollectionMapping() || jaxbMapping.isAbstractCompositeObjectMapping()))) {
      return;
    }
    String adapterClassName=RestAdapterClassWriter.constructClassNameForReferenceAdapter(jpaMapping.getReferenceDescriptor().getJavaClassName());
    try {
      if (jaxbMapping.isAbstractCompositeObjectMapping()) {
        XMLChoiceObjectMapping xmlChoiceMapping=new XMLChoiceObjectMapping();
        xmlChoiceMapping.setAttributeName(attributeName);
        copyAccessorToMapping(jaxbMapping,xmlChoiceMapping);
        xmlChoiceMapping.setProperties(jaxbMapping.getProperties());
        xmlChoiceMapping.addChoiceElement(attributeName,Link.class);
        xmlChoiceMapping.addChoiceElement(attributeName,jpaMapping.getReferenceDescriptor().getJavaClass());
        xmlChoiceMapping.setConverter(new XMLJavaTypeConverter(Class.forName(adapterClassName,true,cl)));
        jaxbDescriptor.removeMappingForAttributeName(jaxbMapping.getAttributeName());
        jaxbDescriptor.addMapping(xmlChoiceMapping);
      }
 else       if (jaxbMapping.isAbstractCompositeCollectionMapping()) {
        XMLChoiceCollectionMapping xmlChoiceMapping=new XMLChoiceCollectionMapping();
        xmlChoiceMapping.setAttributeName(attributeName);
        copyAccessorToMapping(jaxbMapping,xmlChoiceMapping);
        xmlChoiceMapping.setProperties(jaxbMapping.getProperties());
        xmlChoiceMapping.addChoiceElement(attributeName,Link.class);
        xmlChoiceMapping.addChoiceElement(attributeName,jpaMapping.getReferenceDescriptor().getJavaClass());
        xmlChoiceMapping.setConverter(new XMLJavaTypeConverter(Class.forName(adapterClassName,true,cl)));
        jaxbDescriptor.removeMappingForAttributeName(jaxbMapping.getAttributeName());
        jaxbDescriptor.addMapping(xmlChoiceMapping);
      }
    }
 catch (    ClassNotFoundException e) {
      throw new JPARSException(e.toString());
    }
  }
}