Program: 64094
Project: 64094
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)) {
    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());
    }
  }
}

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
 */
@SuppressWarnings("String_Node_Str") private static void convertMappingToXMLChoiceMapping(ClassDescriptor jaxbDescriptor,DatabaseMapping jpaMapping,ClassLoader cl,AbstractSession jpaSession){
  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;
    }
    ClassDescriptor refDesc=jpaMapping.getReferenceDescriptor();
    if (refDesc == null) {
      Class clazz=((ForeignReferenceMapping)jpaMapping).getReferenceClass();
      refDesc=jpaSession.getDescriptor(clazz);
    }
    if (refDesc != null) {
      String adapterClassName=RestAdapterClassWriter.constructClassNameForReferenceAdapter(refDesc.getJavaClassName());
      if (adapterClassName != null) {
        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,refDesc.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,refDesc.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());
        }
      }
    }
  }
}