Program: 64238
Project: 64238
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
 */
protected static void convertMappingToXMLChoiceMapping(ClassDescriptor jaxbDescriptor,DatabaseMapping jpaMapping,ClassLoader cl){
  if ((jpaMapping != null) && (jaxbDescriptor != null)) {
    DatabaseMapping jaxbMapping=jaxbDescriptor.getMappingForAttributeName(jpaMapping.getAttributeName());
    if (!(jaxbMapping.isXMLMapping() && (jaxbMapping.isAbstractCompositeCollectionMapping() || jaxbMapping.isAbstractCompositeObjectMapping()))) {
      return;
    }
    String attributeName=jpaMapping.getAttributeName();
    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,jpaMapping.getReferenceDescriptor().getJavaClass());
        xmlChoiceMapping.addChoiceElement(attributeName,Link.class);
        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)) {
    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,jpaMapping.getReferenceDescriptor().getJavaClass());
        xmlChoiceMapping.addChoiceElement(attributeName,Link.class);
        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());
    }
  }
}