Program: 66157
Project: 66157
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){
  XMLDescriptor descriptor=typeInfo.get(jClass.getName()).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;
  }
  XMLDescriptor 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());
    XMLDescriptor rootDescriptor=rootTypeInfo.getDescriptor();
    if (rootDescriptor.getNamespaceResolver() == null) {
      rootDescriptor.setNamespaceResolver(new NamespaceResolver());
    }
    if (rootDescriptor.getInheritancePolicy().getClassIndicatorField() == null) {
      XMLField classIndicatorField;
      if (rootTypeInfo.isSetXmlDiscriminatorNode()) {
        classIndicatorField=new XMLField(rootTypeInfo.getXmlDiscriminatorNode());
      }
 else {
        String prefix=getPrefixForNamespace(XMLConstants.SCHEMA_INSTANCE_URL,rootDescriptor.getNamespaceResolver(),XMLConstants.SCHEMA_INSTANCE_PREFIX);
        classIndicatorField=new XMLField(ATT + getQualifiedString(prefix,"String_Node_Str"));
      }
      rootDescriptor.getInheritancePolicy().setClassIndicatorField(classIndicatorField);
    }
    String sCtx;
    TypeInfo tInfo=typeInfo.get(jClass.getName());
    if (tInfo.isSetXmlDiscriminatorValue()) {
      sCtx=tInfo.getXmlDiscriminatorValue();
    }
 else {
      sCtx=sRef.getSchemaContext();
      if (sCtx.length() > 1 && sCtx.startsWith("String_Node_Str")) {
        sCtx=sCtx.substring(1);
      }
    }
    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) {
          String rootSCtx=rootSRef.getSchemaContext();
          if (rootSCtx.length() > 1 && rootSCtx.startsWith("String_Node_Str")) {
            rootSCtx=rootSCtx.substring(1);
          }
          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());
  XMLDescriptor 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;
  }
  XMLDescriptor 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());
    XMLDescriptor rootDescriptor=rootTypeInfo.getDescriptor();
    if (rootDescriptor.getNamespaceResolver() == null) {
      rootDescriptor.setNamespaceResolver(new NamespaceResolver());
    }
    if (rootDescriptor.getInheritancePolicy().getClassIndicatorField() == null) {
      XMLField classIndicatorField;
      if (rootTypeInfo.isSetXmlDiscriminatorNode()) {
        classIndicatorField=new XMLField(rootTypeInfo.getXmlDiscriminatorNode());
      }
 else {
        String prefix=getPrefixForNamespace(XMLConstants.SCHEMA_INSTANCE_URL,rootDescriptor.getNamespaceResolver(),XMLConstants.SCHEMA_INSTANCE_PREFIX);
        classIndicatorField=new XMLField(ATT + getQualifiedString(prefix,"String_Node_Str"));
      }
      rootDescriptor.getInheritancePolicy().setClassIndicatorField(classIndicatorField);
    }
    String sCtx=null;
    if (tInfo.isSetXmlDiscriminatorValue()) {
      sCtx=tInfo.getXmlDiscriminatorValue();
    }
 else     if (!tInfo.isAnonymousComplexType()) {
      sCtx=sRef.getSchemaContext();
      if (sCtx.length() > 1 && sCtx.startsWith("String_Node_Str")) {
        sCtx=sCtx.substring(1);
      }
    }
    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) {
          String rootSCtx=rootSRef.getSchemaContext();
          if (rootSCtx.length() > 1 && rootSCtx.startsWith("String_Node_Str")) {
            rootSCtx=rootSCtx.substring(1);
          }
          rootDescriptor.getInheritancePolicy().addClassNameIndicator(rootDescriptor.getJavaClassName(),rootSCtx);
        }
      }
    }
    rootDescriptor.getInheritancePolicy().setShouldReadSubclasses(true);
  }
}