Program: 64754
Project: 64754
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=jpaMapping.getReferenceDescriptor().getJavaClassName() + "String_Node_Str" + RestAdapterClassWriter.ADAPTER_INNER_CLASS_NAME;
    try {
      if (jaxbMapping.isAbstractCompositeObjectMapping()) {
        XMLChoiceObjectMapping xmlChoiceMapping=new XMLChoiceObjectMapping();
        xmlChoiceMapping.setAttributeName(attributeName);
        xmlChoiceMapping.setGetMethodName(jaxbMapping.getGetMethodName());
        xmlChoiceMapping.setSetMethodName(jaxbMapping.getSetMethodName());
        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);
        xmlChoiceMapping.setGetMethodName(jaxbMapping.getGetMethodName());
        xmlChoiceMapping.setSetMethodName(jaxbMapping.getSetMethodName());
        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 RuntimeException(e);
    }
  }
}

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
 */
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=jpaMapping.getReferenceDescriptor().getJavaClassName() + "String_Node_Str" + RestAdapterClassWriter.ADAPTER_INNER_CLASS_NAME;
    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 RuntimeException(e);
    }
  }
}