Program: 64072
Project: 64072
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
 */
@SuppressWarnings("String_Node_Str") private static void convertMappingToXMLChoiceMapping(ClassDescriptor jaxbDescriptor,DatabaseMapping jpaMapping,ClassLoader cl,AbstractSession jpaSession){
  if ((jpaMapping != null) && (jaxbDescriptor != null)) {
    if ((jpaMapping instanceof ForeignReferenceMapping) && ((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=null;
    if (jpaMapping instanceof ForeignReferenceMapping) {
      Class clazz=((ForeignReferenceMapping)jpaMapping).getReferenceClass();
      refDesc=jpaSession.getDescriptor(clazz);
    }
 else     if (jpaMapping instanceof XMLCompositeObjectMapping) {
      Class clazz=((XMLCompositeObjectMapping)jpaMapping).getReferenceClass();
      refDesc=jpaSession.getDescriptor(clazz);
    }
    if (refDesc == null) {
      return;
    }
    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.setContainerPolicy(jaxbMapping.getContainerPolicy());
          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 instanceof ForeignReferenceMapping) && ((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=null;
    if (jpaMapping instanceof ForeignReferenceMapping) {
      Class clazz=((ForeignReferenceMapping)jpaMapping).getReferenceClass();
      refDesc=jpaSession.getDescriptor(clazz);
    }
 else     if (jpaMapping instanceof XMLCompositeObjectMapping) {
      Class clazz=((XMLCompositeObjectMapping)jpaMapping).getReferenceClass();
      refDesc=jpaSession.getDescriptor(clazz);
    }
    if (refDesc == null) {
      return;
    }
    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());
          XMLCompositeObjectMapping compositeMapping=(XMLCompositeObjectMapping)jaxbMapping;
          xmlChoiceMapping.addChoiceElement(compositeMapping.getXPath(),Link.class);
          xmlChoiceMapping.addChoiceElement(compositeMapping.getXPath(),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());
          XMLCompositeCollectionMapping compositeMapping=(XMLCompositeCollectionMapping)jaxbMapping;
          xmlChoiceMapping.addChoiceElement(compositeMapping.getXPath(),Link.class);
          xmlChoiceMapping.addChoiceElement(compositeMapping.getXPath(),refDesc.getJavaClass());
          xmlChoiceMapping.setContainerPolicy(jaxbMapping.getContainerPolicy());
          xmlChoiceMapping.setConverter(new XMLJavaTypeConverter(Class.forName(adapterClassName,true,cl)));
          jaxbDescriptor.removeMappingForAttributeName(jaxbMapping.getAttributeName());
          jaxbDescriptor.addMapping(xmlChoiceMapping);
        }
      }
 catch (      ClassNotFoundException e) {
        throw new JPARSException(e.toString());
      }
    }
  }
}