Program: 67311
Project: 67311
Buggy source:
public void addSchemaComponents(JavaClass myClass){
  String myClassName=myClass.getQualifiedName();
  Element rootElement=null;
  TypeInfo info=(TypeInfo)typeInfo.get(myClassName);
  if (info.isTransient()) {
    return;
  }
  SchemaTypeInfo schemaTypeInfo=new SchemaTypeInfo();
  schemaTypeInfo.setSchemaTypeName(new QName(info.getClassNamespace(),info.getSchemaTypeName()));
  this.schemaTypeInfo.put(myClass.getQualifiedName(),schemaTypeInfo);
  NamespaceInfo namespaceInfo=this.packageToNamespaceMappings.get(myClass.getPackageName());
  if (namespaceInfo.getLocation() != null) {
    return;
  }
  Schema schema=getSchemaForNamespace(info.getClassNamespace());
  info.setSchema(schema);
  String typeName=info.getSchemaTypeName();
  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")) {
      Schema rootElementSchema=getSchemaForNamespace(namespaceInfo.getNamespace());
      if (rootElementSchema != null) {
        rootElementSchema.addTopLevelElement(rootElement);
      }
      schemaTypeInfo.getGlobalElementDeclarations().add(new QName(namespaceInfo.getNamespace(),rootNamespace));
      rootNamespace=namespaceInfo.getNamespace();
    }
 else {
      Schema rootElementSchema=getSchemaForNamespace(rootNamespace);
      if (rootElementSchema != null) {
        rootElementSchema.addTopLevelElement(rootElement);
      }
      schemaTypeInfo.getGlobalElementDeclarations().add(new QName(rootNamespace,elementName));
    }
    Schema rootSchema=getSchemaForNamespace(rootNamespace);
    addImportIfRequired(rootSchema,schema,schema.getTargetNamespace());
    if (rootSchema != null && !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=null;
      if (valueField.getType().isArray()) {
        baseType=getSchemaTypeFor(valueField.getType().getComponentType());
      }
 else       if (valueField.getGenericType() != null) {
        baseType=getSchemaTypeFor(valueField.getGenericType());
      }
 else {
        baseType=getSchemaTypeFor(valueField.getType());
      }
      String prefix=null;
      if (baseType.getNamespaceURI() != null && !baseType.getNamespaceURI().equals("String_Node_Str")) {
        if (baseType.getNamespaceURI().equals(XMLConstants.SCHEMA_URL)) {
          prefix=XMLConstants.SCHEMA_PREFIX;
        }
 else {
          prefix=getPrefixForNamespace(baseType.getNamespaceURI(),schema.getNamespaceResolver());
        }
      }
      String baseTypeName=baseType.getLocalPart();
      if (prefix != null) {
        baseTypeName=prefix + "String_Node_Str" + baseTypeName;
      }
      if (helper.isAnnotationPresent(valueField.getElement(),XmlList.class) || isCollectionType(valueField)) {
        List list=new List();
        list.setItemType(baseTypeName);
        type.setList(list);
      }
 else {
        if (helper.isAnnotationPresent(valueField.getElement(),XmlSchemaType.class)) {
          XmlSchemaType schemaType=(XmlSchemaType)helper.getAnnotation(valueField.getElement(),XmlSchemaType.class);
          baseType=new QName(schemaType.namespace(),schemaType.name());
        }
        restriction.setBaseType(baseTypeName);
        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(schemaType.namespace(),schemaType.name());
    }
    String prefix=null;
    if (extensionType.getNamespaceURI() != null && !extensionType.getNamespaceURI().equals("String_Node_Str")) {
      if (extensionType.getNamespaceURI().equals(XMLConstants.SCHEMA_URL)) {
        prefix=XMLConstants.SCHEMA_PREFIX;
      }
 else {
        prefix=getPrefixForNamespace(extensionType.getNamespaceURI(),schema.getNamespaceResolver());
      }
    }
    String extensionTypeName=extensionType.getLocalPart();
    if (prefix != null) {
      extensionTypeName=prefix + "String_Node_Str" + extensionTypeName;
    }
    Extension extension=new Extension();
    extension.setBaseType(extensionTypeName);
    content.setExtension(extension);
    type.setSimpleContent(content);
    info.setComplexType(type);
  }
 else {
    ComplexType type=new ComplexType();
    JavaClass superClass=helper.getNextMappedSuperClass(myClass);
    if (info.isMixed()) {
      type.setMixed(true);
    }
    if (myClass.isAbstract()) {
      type.setAbstractValue(true);
    }
    Extension extension=null;
    if (superClass != null) {
      TypeInfo parentTypeInfo=this.typeInfo.get(superClass.getQualifiedName());
      if (parentTypeInfo != null) {
        extension=new Extension();
        String parentPrefix=getPrefixForNamespace(parentTypeInfo.getClassNamespace(),schema.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;
    String[] propOrder=info.getPropOrder();
    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);
    }
  }
}

Fixed version (ground truth):
public void addSchemaComponents(JavaClass myClass){
  String myClassName=myClass.getQualifiedName();
  Element rootElement=null;
  TypeInfo info=(TypeInfo)typeInfo.get(myClassName);
  if (info.isTransient()) {
    return;
  }
  SchemaTypeInfo schemaTypeInfo=new SchemaTypeInfo();
  schemaTypeInfo.setSchemaTypeName(new QName(info.getClassNamespace(),info.getSchemaTypeName()));
  this.schemaTypeInfo.put(myClass.getQualifiedName(),schemaTypeInfo);
  NamespaceInfo namespaceInfo=this.packageToNamespaceMappings.get(myClass.getPackageName());
  if (namespaceInfo.getLocation() != null && !namespaceInfo.getLocation().equals("String_Node_Str")) {
    return;
  }
  Schema schema=getSchemaForNamespace(info.getClassNamespace());
  info.setSchema(schema);
  String typeName=info.getSchemaTypeName();
  String pfx="String_Node_Str";
  Property valueField=null;
  if (info.isSetXmlRootElement()) {
    org.eclipse.persistence.jaxb.xmlmodel.XmlRootElement xmlRE=info.getXmlRootElement();
    rootElement=new Element();
    String elementName=xmlRE.getName();
    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=xmlRE.getNamespace();
    if (rootNamespace.equals("String_Node_Str")) {
      Schema rootElementSchema=getSchemaForNamespace(namespaceInfo.getNamespace());
      if (rootElementSchema != null) {
        rootElementSchema.addTopLevelElement(rootElement);
      }
      schemaTypeInfo.getGlobalElementDeclarations().add(new QName(namespaceInfo.getNamespace(),rootNamespace));
      rootNamespace=namespaceInfo.getNamespace();
    }
 else {
      Schema rootElementSchema=getSchemaForNamespace(rootNamespace);
      if (rootElementSchema != null) {
        rootElementSchema.addTopLevelElement(rootElement);
      }
      schemaTypeInfo.getGlobalElementDeclarations().add(new QName(rootNamespace,elementName));
    }
    Schema rootSchema=getSchemaForNamespace(rootNamespace);
    addImportIfRequired(rootSchema,schema,schema.getTargetNamespace());
    if (rootSchema != null && !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=null;
      if (valueField.getType().isArray()) {
        baseType=getSchemaTypeFor(valueField.getType().getComponentType());
      }
 else       if (valueField.getGenericType() != null) {
        baseType=getSchemaTypeFor(valueField.getGenericType());
      }
 else {
        baseType=getSchemaTypeFor(valueField.getType());
      }
      String prefix=null;
      if (baseType.getNamespaceURI() != null && !baseType.getNamespaceURI().equals("String_Node_Str")) {
        if (baseType.getNamespaceURI().equals(XMLConstants.SCHEMA_URL)) {
          prefix=XMLConstants.SCHEMA_PREFIX;
        }
 else {
          prefix=getPrefixForNamespace(baseType.getNamespaceURI(),schema.getNamespaceResolver());
        }
      }
      String baseTypeName=baseType.getLocalPart();
      if (prefix != null) {
        baseTypeName=prefix + "String_Node_Str" + baseTypeName;
      }
      if (helper.isAnnotationPresent(valueField.getElement(),XmlList.class) || isCollectionType(valueField)) {
        List list=new List();
        list.setItemType(baseTypeName);
        type.setList(list);
      }
 else {
        if (helper.isAnnotationPresent(valueField.getElement(),XmlSchemaType.class)) {
          XmlSchemaType schemaType=(XmlSchemaType)helper.getAnnotation(valueField.getElement(),XmlSchemaType.class);
          baseType=new QName(schemaType.namespace(),schemaType.name());
        }
        restriction.setBaseType(baseTypeName);
        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(schemaType.namespace(),schemaType.name());
    }
    String prefix=null;
    if (extensionType.getNamespaceURI() != null && !extensionType.getNamespaceURI().equals("String_Node_Str")) {
      if (extensionType.getNamespaceURI().equals(XMLConstants.SCHEMA_URL)) {
        prefix=XMLConstants.SCHEMA_PREFIX;
      }
 else {
        prefix=getPrefixForNamespace(extensionType.getNamespaceURI(),schema.getNamespaceResolver());
      }
    }
    String extensionTypeName=extensionType.getLocalPart();
    if (prefix != null) {
      extensionTypeName=prefix + "String_Node_Str" + extensionTypeName;
    }
    Extension extension=new Extension();
    extension.setBaseType(extensionTypeName);
    content.setExtension(extension);
    type.setSimpleContent(content);
    info.setComplexType(type);
  }
 else {
    ComplexType type=new ComplexType();
    JavaClass superClass=helper.getNextMappedSuperClass(myClass);
    if (info.isMixed()) {
      type.setMixed(true);
    }
    if (myClass.isAbstract()) {
      type.setAbstractValue(true);
    }
    Extension extension=null;
    if (superClass != null) {
      TypeInfo parentTypeInfo=this.typeInfo.get(superClass.getQualifiedName());
      if (parentTypeInfo != null) {
        extension=new Extension();
        String parentPrefix=getPrefixForNamespace(parentTypeInfo.getClassNamespace(),schema.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;
    String[] propOrder=null;
    if (info.isSetPropOrder()) {
      propOrder=info.getPropOrder();
    }
    if (propOrder != null && 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);
    }
  }
}