Program: 64431
Project: 64431
Buggy source:
/** 
 * Setup inheritance for abstract superclass. NOTE: We currently only handle one level of inheritance in this case. For multiple levels the code will need to be modified. The logic in generateMappings() that determines when to copy down inherited methods from the parent class will need to be changed as well.
 * @param jClass
 */
private void setupInheritance(JavaClass jClass){
  TypeInfo tInfo=typeInfo.get(jClass.getName());
  Descriptor descriptor=tInfo.getDescriptor();
  if (descriptor == null) {
    return;
  }
  JavaClass superClass=CompilerHelper.getNextMappedSuperClass(jClass,typeInfo,helper);
  if (superClass == null) {
    return;
  }
  TypeInfo superTypeInfo=typeInfo.get(superClass.getName());
  if (superTypeInfo == null) {
    return;
  }
  Descriptor superDescriptor=superTypeInfo.getDescriptor();
  if (superDescriptor != null) {
    XMLSchemaReference sRef=descriptor.getSchemaReference();
    if (sRef == null || sRef.getSchemaContext() == null) {
      return;
    }
    JavaClass rootMappedSuperClass=getRootMappedSuperClass(superClass);
    TypeInfo rootTypeInfo=typeInfo.get(rootMappedSuperClass.getName());
    Descriptor rootDescriptor=rootTypeInfo.getDescriptor();
    if (rootDescriptor.getNamespaceResolver() == null) {
      rootDescriptor.setNamespaceResolver(new NamespaceResolver());
    }
    if (rootDescriptor.getInheritancePolicy().getClassIndicatorField() == null) {
      Field classIndicatorField;
      if (rootTypeInfo.isSetXmlDiscriminatorNode()) {
        classIndicatorField=new XMLField(rootTypeInfo.getXmlDiscriminatorNode());
      }
 else {
        classIndicatorField=new XMLField(ATT + "String_Node_Str");
        classIndicatorField.getXPathFragment().setNamespaceURI(XMLConstants.SCHEMA_INSTANCE_URL);
      }
      rootDescriptor.getInheritancePolicy().setClassIndicatorField(classIndicatorField);
    }
    Object sCtx=null;
    if (tInfo.isSetXmlDiscriminatorValue()) {
      sCtx=tInfo.getXmlDiscriminatorValue();
    }
 else     if (!tInfo.isAnonymousComplexType()) {
      sCtx=sRef.getSchemaContextAsQName();
    }
    if (sCtx != null) {
      descriptor.getInheritancePolicy().setParentClassName(superClass.getName());
      rootDescriptor.getInheritancePolicy().addClassNameIndicator(jClass.getName(),sCtx);
    }
    Object value=rootDescriptor.getInheritancePolicy().getClassNameIndicatorMapping().get(rootDescriptor.getJavaClassName());
    if (value == null) {
      if (rootTypeInfo.isSetXmlDiscriminatorValue()) {
        rootDescriptor.getInheritancePolicy().addClassNameIndicator(rootDescriptor.getJavaClassName(),rootTypeInfo.getXmlDiscriminatorValue());
      }
 else {
        XMLSchemaReference rootSRef=rootDescriptor.getSchemaReference();
        if (rootSRef != null && rootSRef.getSchemaContext() != null) {
          QName rootSCtx=rootSRef.getSchemaContextAsQName();
          rootDescriptor.getInheritancePolicy().addClassNameIndicator(rootDescriptor.getJavaClassName(),rootSCtx);
        }
      }
    }
    rootDescriptor.getInheritancePolicy().setShouldReadSubclasses(true);
  }
}

Fixed version (ground truth):
/** 
 * Setup inheritance for abstract superclass. NOTE: We currently only handle one level of inheritance in this case. For multiple levels the code will need to be modified. The logic in generateMappings() that determines when to copy down inherited methods from the parent class will need to be changed as well.
 * @param jClass
 */
private void setupInheritance(JavaClass jClass){
  TypeInfo tInfo=typeInfo.get(jClass.getName());
  Descriptor descriptor=tInfo.getDescriptor();
  if (descriptor == null) {
    return;
  }
  JavaClass superClass=CompilerHelper.getNextMappedSuperClass(jClass,typeInfo,helper);
  if (superClass == null) {
    return;
  }
  TypeInfo superTypeInfo=typeInfo.get(superClass.getName());
  if (superTypeInfo == null) {
    return;
  }
  Descriptor superDescriptor=superTypeInfo.getDescriptor();
  if (superDescriptor != null) {
    XMLSchemaReference sRef=descriptor.getSchemaReference();
    if (sRef == null || sRef.getSchemaContext() == null) {
      return;
    }
    JavaClass rootMappedSuperClass=getRootMappedSuperClass(superClass);
    TypeInfo rootTypeInfo=typeInfo.get(rootMappedSuperClass.getName());
    Descriptor rootDescriptor=rootTypeInfo.getDescriptor();
    if (rootDescriptor.getNamespaceResolver() == null) {
      rootDescriptor.setNamespaceResolver(new org.eclipse.persistence.oxm.NamespaceResolver());
    }
    if (rootDescriptor.getInheritancePolicy().getClassIndicatorField() == null) {
      Field classIndicatorField;
      if (rootTypeInfo.isSetXmlDiscriminatorNode()) {
        classIndicatorField=new XMLField(rootTypeInfo.getXmlDiscriminatorNode());
      }
 else {
        classIndicatorField=new XMLField(ATT + "String_Node_Str");
        classIndicatorField.getXPathFragment().setNamespaceURI(XMLConstants.SCHEMA_INSTANCE_URL);
      }
      rootDescriptor.getInheritancePolicy().setClassIndicatorField(classIndicatorField);
    }
    Object sCtx=null;
    if (tInfo.isSetXmlDiscriminatorValue()) {
      sCtx=tInfo.getXmlDiscriminatorValue();
    }
 else     if (!tInfo.isAnonymousComplexType()) {
      sCtx=sRef.getSchemaContextAsQName();
    }
    if (sCtx != null) {
      descriptor.getInheritancePolicy().setParentClassName(superClass.getName());
      rootDescriptor.getInheritancePolicy().addClassNameIndicator(jClass.getName(),sCtx);
    }
    Object value=rootDescriptor.getInheritancePolicy().getClassNameIndicatorMapping().get(rootDescriptor.getJavaClassName());
    if (value == null) {
      if (rootTypeInfo.isSetXmlDiscriminatorValue()) {
        rootDescriptor.getInheritancePolicy().addClassNameIndicator(rootDescriptor.getJavaClassName(),rootTypeInfo.getXmlDiscriminatorValue());
      }
 else {
        XMLSchemaReference rootSRef=rootDescriptor.getSchemaReference();
        if (rootSRef != null && rootSRef.getSchemaContext() != null) {
          QName rootSCtx=rootSRef.getSchemaContextAsQName();
          rootDescriptor.getInheritancePolicy().addClassNameIndicator(rootDescriptor.getJavaClassName(),rootSCtx);
        }
      }
    }
    rootDescriptor.getInheritancePolicy().setShouldReadSubclasses(true);
  }
}