Program: 68050
Project: 68050
Buggy source:
public void addSchemaComponents(JavaClass myClass){
  String myClassName=myClass.getQualifiedName();
  Element rootElement=null;
  TypeInfo info=(TypeInfo)typeInfo.get(myClassName);
  SchemaTypeInfo schemaTypeInfo=new SchemaTypeInfo();
  schemaTypeInfo.setSchemaTypeName(new QName(info.getClassNamespace(),info.getSchemaTypeName()));
  this.schemaTypeInfo.put(myClass.getQualifiedName(),schemaTypeInfo);
  NamespaceInfo namespaceInfo=this.packageToNamespaceMappings.get(myClass.getPackage().getQualifiedName());
  Schema schema=getSchemaForNamespace(info.getClassNamespace());
  info.setSchema(schema);
  String typeName=info.getSchemaTypeName();
  String[] propOrder=info.getPropOrder();
  String pfx="String_Node_Str";
  Property valueField=null;
  if (helper.isAnnotationPresent(myClass,XmlRootElement.class)) {
    XmlRootElement rootElemAnnotation=(XmlRootElement)helper.getAnnotation(myClass,XmlRootElement.class);
    rootElement=new Element();
    String elementName=rootElemAnnotation.name();
    if (elementName.equals("String_Node_Str") || elementName.equals("String_Node_Str")) {
      if (myClassName.indexOf("String_Node_Str") != -1) {
        elementName=Introspector.decapitalize(myClassName.substring(myClassName.lastIndexOf('$') + 1));
      }
 else {
        elementName=Introspector.decapitalize(myClassName.substring(myClassName.lastIndexOf('.') + 1));
      }
      if (elementName.length() >= 3) {
        int idx=elementName.length() - 1;
        char ch=elementName.charAt(idx - 1);
        if (Character.isDigit(ch)) {
          char lastCh=Character.toUpperCase(elementName.charAt(idx));
          elementName=elementName.substring(0,idx) + lastCh;
        }
      }
    }
    rootElement.setName(elementName);
    String rootNamespace=rootElemAnnotation.namespace();
    if (rootNamespace.equals("String_Node_Str")) {
      getSchemaForNamespace(namespaceInfo.getNamespace()).addTopLevelElement(rootElement);
      schemaTypeInfo.getGlobalElementDeclarations().add(new QName(namespaceInfo.getNamespace(),rootNamespace));
      rootNamespace=namespaceInfo.getNamespace();
    }
 else {
      getSchemaForNamespace(rootNamespace).addTopLevelElement(rootElement);
      schemaTypeInfo.getGlobalElementDeclarations().add(new QName(rootNamespace,elementName));
    }
    Schema rootSchema=getSchemaForNamespace(rootNamespace);
    if (schema != rootSchema) {
      Import schemaImport=new Import();
      schemaImport.setNamespace(schema.getTargetNamespace());
      schemaImport.setSchemaLocation(schema.getName());
      rootSchema.getImports().add(schemaImport);
    }
    if (!info.getClassNamespace().equals("String_Node_Str")) {
      pfx=getPrefixForNamespace(info.getClassNamespace(),rootSchema.getNamespaceResolver());
      if (pfx == null) {
        pfx=rootSchema.getNamespaceResolver().generatePrefix();
        rootSchema.getNamespaceResolver().put(pfx,info.getClassNamespace());
      }
      pfx+="String_Node_Str";
    }
  }
  ArrayList<String> propertyNames=info.getPropertyNames();
  if (info.isEnumerationType() || (propertyNames.size() == 1 && helper.isAnnotationPresent(info.getProperties().get(propertyNames.get(0)).getElement(),XmlValue.class))) {
    SimpleType type=new SimpleType();
    if (typeName.equals("String_Node_Str")) {
      if (rootElement != null) {
        rootElement.setSimpleType(type);
      }
    }
 else {
      type.setName(typeName);
      schema.addTopLevelSimpleTypes(type);
      if (rootElement != null) {
        rootElement.setType(pfx + type.getName());
      }
    }
    QName restrictionType=null;
    Restriction restriction=new Restriction();
    if (info.isEnumerationType()) {
      restrictionType=((EnumTypeInfo)info).getRestrictionBase();
      restriction.setEnumerationFacets(this.getEnumerationFacetsFor((EnumTypeInfo)info));
      restriction.setBaseType(XMLConstants.SCHEMA_PREFIX + "String_Node_Str" + restrictionType.getLocalPart());
      type.setRestriction(restriction);
    }
 else {
      valueField=info.getProperties().get(propertyNames.get(0));
      QName baseType=getSchemaTypeFor(valueField.getType());
      if (helper.isAnnotationPresent(valueField.getElement(),XmlList.class)) {
        List list=new List();
        list.setItemType(XMLConstants.SCHEMA_PREFIX + "String_Node_Str" + baseType.getLocalPart());
        type.setList(list);
      }
 else {
        if (helper.isAnnotationPresent(valueField.getElement(),XmlSchemaType.class)) {
          XmlSchemaType schemaType=(XmlSchemaType)helper.getAnnotation(valueField.getElement(),XmlSchemaType.class);
          baseType=new QName(XMLConstants.SCHEMA_INSTANCE_URL,schemaType.name());
        }
        restriction.setBaseType(XMLConstants.SCHEMA_PREFIX + "String_Node_Str" + baseType.getLocalPart());
        type.setRestriction(restriction);
      }
    }
    info.setSimpleType(type);
  }
 else   if ((valueField=this.getXmlValueFieldForSimpleContent(info.getPropertyList())) != null) {
    ComplexType type=new ComplexType();
    SimpleContent content=new SimpleContent();
    if (typeName.equals("String_Node_Str")) {
      if (rootElement != null) {
        rootElement.setComplexType(type);
      }
      info.setComplexType(type);
    }
 else {
      type.setName(typeName);
      schema.addTopLevelComplexTypes(type);
      if (rootElement != null) {
        rootElement.setType(pfx + type.getName());
      }
    }
    QName extensionType=getSchemaTypeFor(valueField.getType());
    if (helper.isAnnotationPresent(valueField.getElement(),XmlSchemaType.class)) {
      XmlSchemaType schemaType=(XmlSchemaType)helper.getAnnotation(valueField.getElement(),XmlSchemaType.class);
      extensionType=new QName(XMLConstants.SCHEMA_INSTANCE_URL,schemaType.name());
    }
    Extension extension=new Extension();
    extension.setBaseType(XMLConstants.SCHEMA_PREFIX + "String_Node_Str" + extensionType.getLocalPart());
    content.setExtension(extension);
    type.setSimpleContent(content);
    info.setComplexType(type);
    info.setPropOrder(propOrder);
  }
 else {
    ComplexType type=new ComplexType();
    JavaClass superClass=(JavaClass)myClass.getSuperclass();
    TypeInfo parentTypeInfo=this.typeInfo.get(superClass.getQualifiedName());
    Extension extension=null;
    if (parentTypeInfo != null) {
      extension=new Extension();
      String parentPrefix=getPrefixForNamespace(parentTypeInfo.getClassNamespace(),namespaceInfo.getNamespaceResolver());
      if (parentPrefix != null) {
        extension.setBaseType(parentPrefix + "String_Node_Str" + parentTypeInfo.getSchemaTypeName());
      }
 else {
        extension.setBaseType(parentTypeInfo.getSchemaTypeName());
      }
      ComplexContent content=new ComplexContent();
      content.setExtension(extension);
      type.setComplexContent(content);
    }
    TypeDefParticle compositor=null;
    if (propOrder.length == 0) {
      if (info.hasElementRefs()) {
        compositor=new Sequence();
        if (extension != null) {
          extension.setSequence((Sequence)compositor);
        }
 else {
          type.setSequence((Sequence)compositor);
        }
      }
 else       if (extension != null) {
        compositor=new All();
        extension.setAll((All)compositor);
      }
 else {
        compositor=new All();
        type.setAll((All)compositor);
      }
    }
 else {
      compositor=new Sequence();
      if (extension != null) {
        extension.setSequence((Sequence)compositor);
      }
 else {
        type.setSequence((Sequence)compositor);
      }
    }
    if (typeName.equals("String_Node_Str")) {
      if (rootElement != null) {
        rootElement.setComplexType(type);
      }
      info.setComplexType(type);
      info.setCompositor(compositor);
    }
 else {
      type.setName(typeName);
      if (rootElement != null) {
        rootElement.setType(pfx + type.getName());
      }
      schema.addTopLevelComplexTypes(type);
      info.setComplexType(type);
      info.setCompositor(compositor);
    }
    info.setPropOrder(propOrder);
  }
}

Fixed version (ground truth):
public void addSchemaComponents(JavaClass myClass){
  String myClassName=myClass.getQualifiedName();
  Element rootElement=null;
  TypeInfo info=(TypeInfo)typeInfo.get(myClassName);
  SchemaTypeInfo schemaTypeInfo=new SchemaTypeInfo();
  schemaTypeInfo.setSchemaTypeName(new QName(info.getClassNamespace(),info.getSchemaTypeName()));
  this.schemaTypeInfo.put(myClass.getQualifiedName(),schemaTypeInfo);
  NamespaceInfo namespaceInfo=this.packageToNamespaceMappings.get(myClass.getPackage().getQualifiedName());
  Schema schema=getSchemaForNamespace(info.getClassNamespace());
  info.setSchema(schema);
  String typeName=info.getSchemaTypeName();
  String[] propOrder=info.getPropOrder();
  String pfx="String_Node_Str";
  Property valueField=null;
  if (helper.isAnnotationPresent(myClass,XmlRootElement.class)) {
    XmlRootElement rootElemAnnotation=(XmlRootElement)helper.getAnnotation(myClass,XmlRootElement.class);
    rootElement=new Element();
    String elementName=rootElemAnnotation.name();
    if (elementName.equals("String_Node_Str") || elementName.equals("String_Node_Str")) {
      if (myClassName.indexOf("String_Node_Str") != -1) {
        elementName=Introspector.decapitalize(myClassName.substring(myClassName.lastIndexOf('$') + 1));
      }
 else {
        elementName=Introspector.decapitalize(myClassName.substring(myClassName.lastIndexOf('.') + 1));
      }
      if (elementName.length() >= 3) {
        int idx=elementName.length() - 1;
        char ch=elementName.charAt(idx - 1);
        if (Character.isDigit(ch)) {
          char lastCh=Character.toUpperCase(elementName.charAt(idx));
          elementName=elementName.substring(0,idx) + lastCh;
        }
      }
    }
    rootElement.setName(elementName);
    String rootNamespace=rootElemAnnotation.namespace();
    if (rootNamespace.equals("String_Node_Str")) {
      getSchemaForNamespace(namespaceInfo.getNamespace()).addTopLevelElement(rootElement);
      schemaTypeInfo.getGlobalElementDeclarations().add(new QName(namespaceInfo.getNamespace(),rootNamespace));
      rootNamespace=namespaceInfo.getNamespace();
    }
 else {
      getSchemaForNamespace(rootNamespace).addTopLevelElement(rootElement);
      schemaTypeInfo.getGlobalElementDeclarations().add(new QName(rootNamespace,elementName));
    }
    Schema rootSchema=getSchemaForNamespace(rootNamespace);
    if (schema != rootSchema) {
      Import schemaImport=new Import();
      schemaImport.setNamespace(schema.getTargetNamespace());
      schemaImport.setSchemaLocation(schema.getName());
      rootSchema.getImports().add(schemaImport);
    }
    if (!info.getClassNamespace().equals("String_Node_Str")) {
      pfx=getPrefixForNamespace(info.getClassNamespace(),rootSchema.getNamespaceResolver());
      if (pfx == null) {
        pfx=rootSchema.getNamespaceResolver().generatePrefix();
        rootSchema.getNamespaceResolver().put(pfx,info.getClassNamespace());
      }
      pfx+="String_Node_Str";
    }
  }
  ArrayList<String> propertyNames=info.getPropertyNames();
  if (info.isEnumerationType() || (propertyNames.size() == 1 && helper.isAnnotationPresent(info.getProperties().get(propertyNames.get(0)).getElement(),XmlValue.class))) {
    SimpleType type=new SimpleType();
    if (typeName.equals("String_Node_Str")) {
      if (rootElement != null) {
        rootElement.setSimpleType(type);
      }
    }
 else {
      type.setName(typeName);
      schema.addTopLevelSimpleTypes(type);
      if (rootElement != null) {
        rootElement.setType(pfx + type.getName());
      }
    }
    QName restrictionType=null;
    Restriction restriction=new Restriction();
    if (info.isEnumerationType()) {
      restrictionType=((EnumTypeInfo)info).getRestrictionBase();
      restriction.setEnumerationFacets(this.getEnumerationFacetsFor((EnumTypeInfo)info));
      restriction.setBaseType(XMLConstants.SCHEMA_PREFIX + "String_Node_Str" + restrictionType.getLocalPart());
      type.setRestriction(restriction);
    }
 else {
      valueField=info.getProperties().get(propertyNames.get(0));
      QName baseType=getSchemaTypeFor(valueField.getType());
      if (helper.isAnnotationPresent(valueField.getElement(),XmlList.class)) {
        List list=new List();
        list.setItemType(XMLConstants.SCHEMA_PREFIX + "String_Node_Str" + baseType.getLocalPart());
        type.setList(list);
      }
 else {
        if (helper.isAnnotationPresent(valueField.getElement(),XmlSchemaType.class)) {
          XmlSchemaType schemaType=(XmlSchemaType)helper.getAnnotation(valueField.getElement(),XmlSchemaType.class);
          baseType=new QName(XMLConstants.SCHEMA_INSTANCE_URL,schemaType.name());
        }
        restriction.setBaseType(XMLConstants.SCHEMA_PREFIX + "String_Node_Str" + baseType.getLocalPart());
        type.setRestriction(restriction);
      }
    }
    info.setSimpleType(type);
  }
 else   if ((valueField=this.getXmlValueFieldForSimpleContent(info.getPropertyList())) != null) {
    ComplexType type=new ComplexType();
    SimpleContent content=new SimpleContent();
    if (typeName.equals("String_Node_Str")) {
      if (rootElement != null) {
        rootElement.setComplexType(type);
      }
      info.setComplexType(type);
    }
 else {
      type.setName(typeName);
      schema.addTopLevelComplexTypes(type);
      if (rootElement != null) {
        rootElement.setType(pfx + type.getName());
      }
    }
    QName extensionType=getSchemaTypeFor(valueField.getType());
    if (helper.isAnnotationPresent(valueField.getElement(),XmlSchemaType.class)) {
      XmlSchemaType schemaType=(XmlSchemaType)helper.getAnnotation(valueField.getElement(),XmlSchemaType.class);
      extensionType=new QName(XMLConstants.SCHEMA_INSTANCE_URL,schemaType.name());
    }
    Extension extension=new Extension();
    extension.setBaseType(XMLConstants.SCHEMA_PREFIX + "String_Node_Str" + extensionType.getLocalPart());
    content.setExtension(extension);
    type.setSimpleContent(content);
    info.setComplexType(type);
  }
 else {
    ComplexType type=new ComplexType();
    JavaClass superClass=(JavaClass)myClass.getSuperclass();
    TypeInfo parentTypeInfo=this.typeInfo.get(superClass.getQualifiedName());
    Extension extension=null;
    if (parentTypeInfo != null) {
      extension=new Extension();
      String parentPrefix=getPrefixForNamespace(parentTypeInfo.getClassNamespace(),namespaceInfo.getNamespaceResolver());
      if (parentPrefix != null) {
        extension.setBaseType(parentPrefix + "String_Node_Str" + parentTypeInfo.getSchemaTypeName());
      }
 else {
        extension.setBaseType(parentTypeInfo.getSchemaTypeName());
      }
      ComplexContent content=new ComplexContent();
      content.setExtension(extension);
      type.setComplexContent(content);
    }
    TypeDefParticle compositor=null;
    if (propOrder.length == 0) {
      if (info.hasElementRefs()) {
        compositor=new Sequence();
        if (extension != null) {
          extension.setSequence((Sequence)compositor);
        }
 else {
          type.setSequence((Sequence)compositor);
        }
      }
 else       if (extension != null) {
        compositor=new All();
        extension.setAll((All)compositor);
      }
 else {
        compositor=new All();
        type.setAll((All)compositor);
      }
    }
 else {
      compositor=new Sequence();
      if (extension != null) {
        extension.setSequence((Sequence)compositor);
      }
 else {
        type.setSequence((Sequence)compositor);
      }
    }
    if (typeName.equals("String_Node_Str")) {
      if (rootElement != null) {
        rootElement.setComplexType(type);
      }
      info.setComplexType(type);
      info.setCompositor(compositor);
    }
 else {
      type.setName(typeName);
      if (rootElement != null) {
        rootElement.setType(pfx + type.getName());
      }
      schema.addTopLevelComplexTypes(type);
      info.setComplexType(type);
      info.setCompositor(compositor);
    }
    info.setPropOrder(propOrder);
  }
}