Program: 66301
Project: 66301
Buggy source:
public JavaClass[] processObjectFactory(JavaClass objectFactoryClass,ArrayList<JavaClass> classes){
  Map<String,org.eclipse.persistence.jaxb.xmlmodel.XmlRegistry.XmlElementDecl> elemDecls=new HashMap<String,org.eclipse.persistence.jaxb.xmlmodel.XmlRegistry.XmlElementDecl>();
  org.eclipse.persistence.jaxb.xmlmodel.XmlRegistry xmlReg=xmlRegistries.get(objectFactoryClass.getQualifiedName());
  if (xmlReg != null) {
    for (    org.eclipse.persistence.jaxb.xmlmodel.XmlRegistry.XmlElementDecl xmlElementDecl : xmlReg.getXmlElementDecl()) {
      elemDecls.put(xmlElementDecl.getJavaMethod(),xmlElementDecl);
    }
  }
  Collection methods=objectFactoryClass.getDeclaredMethods();
  Iterator methodsIter=methods.iterator();
  NamespaceInfo namespaceInfo=getNamespaceInfoForPackage(objectFactoryClass);
  while (methodsIter.hasNext()) {
    JavaMethod next=(JavaMethod)methodsIter.next();
    if (next.getName().startsWith("String_Node_Str")) {
      JavaClass type=next.getReturnType();
      if (type.getName().equals("String_Node_Str")) {
        type=(JavaClass)next.getReturnType().getActualTypeArguments().toArray()[0];
      }
 else {
        this.factoryMethods.put(next.getReturnType().getRawName(),next);
      }
      org.eclipse.persistence.jaxb.xmlmodel.XmlRegistry.XmlElementDecl xmlEltDecl=elemDecls.get(next.getName());
      if (xmlEltDecl != null || helper.isAnnotationPresent(next,XmlElementDecl.class)) {
        QName qname;
        QName substitutionHead=null;
        String url;
        String localName;
        String defaultValue=null;
        Class scopeClass=javax.xml.bind.annotation.XmlElementDecl.GLOBAL.class;
        if (xmlEltDecl != null) {
          url=xmlEltDecl.getNamespace();
          localName=xmlEltDecl.getName();
          String scopeClassName=xmlEltDecl.getScope();
          if (!scopeClassName.equals("String_Node_Str")) {
            JavaClass jScopeClass=helper.getJavaClass(scopeClassName);
            if (jScopeClass != null) {
              scopeClass=helper.getClassForJavaClass(jScopeClass);
              if (scopeClass == null) {
                scopeClass=javax.xml.bind.annotation.XmlElementDecl.GLOBAL.class;
              }
            }
          }
          if (!xmlEltDecl.getSubstitutionHeadName().equals("String_Node_Str")) {
            String subHeadLocal=xmlEltDecl.getSubstitutionHeadName();
            String subHeadNamespace=xmlEltDecl.getSubstitutionHeadNamespace();
            if (subHeadNamespace.equals("String_Node_Str")) {
              subHeadNamespace=namespaceInfo.getNamespace();
            }
            substitutionHead=new QName(subHeadNamespace,subHeadLocal);
          }
          if (!(xmlEltDecl.getDefaultValue().length() == 1 && xmlEltDecl.getDefaultValue().startsWith("String_Node_Str"))) {
            defaultValue=xmlEltDecl.getDefaultValue();
          }
        }
 else {
          XmlElementDecl elementDecl=(XmlElementDecl)helper.getAnnotation(next,XmlElementDecl.class);
          url=elementDecl.namespace();
          localName=elementDecl.name();
          scopeClass=elementDecl.scope();
          if (!elementDecl.substitutionHeadName().equals("String_Node_Str")) {
            String subHeadLocal=elementDecl.substitutionHeadName();
            String subHeadNamespace=elementDecl.substitutionHeadNamespace();
            if (subHeadNamespace.equals("String_Node_Str")) {
              subHeadNamespace=namespaceInfo.getNamespace();
            }
            substitutionHead=new QName(subHeadNamespace,subHeadLocal);
          }
          if (!(elementDecl.defaultValue().length() == 1 && elementDecl.defaultValue().startsWith("String_Node_Str"))) {
            defaultValue=elementDecl.defaultValue();
          }
        }
        if ("String_Node_Str".equals(url)) {
          url=namespaceInfo.getNamespace();
        }
        qname=new QName(url,localName);
        boolean isList=false;
        if ("String_Node_Str".equals(type.getName())) {
          isList=true;
          if (type.hasActualTypeArguments()) {
            type=(JavaClass)type.getActualTypeArguments().toArray()[0];
          }
        }
        ElementDeclaration declaration=new ElementDeclaration(qname,type,type.getQualifiedName(),isList,scopeClass);
        if (substitutionHead != null) {
          declaration.setSubstitutionHead(substitutionHead);
        }
        if (defaultValue != null) {
          declaration.setDefaultValue(defaultValue);
        }
        if (helper.isAnnotationPresent(next,XmlJavaTypeAdapter.class)) {
          XmlJavaTypeAdapter typeAdapter=(XmlJavaTypeAdapter)helper.getAnnotation(next,XmlJavaTypeAdapter.class);
          Class typeAdapterClass=typeAdapter.value();
          declaration.setJavaTypeAdapterClass(typeAdapterClass);
          Method[] tacMethods=typeAdapterClass.getMethods();
          Class declJavaType=CompilerHelper.getTypeFromAdapterClass(typeAdapterClass);
          declaration.setJavaType(helper.getJavaClass(declJavaType));
          declaration.setAdaptedJavaType(type);
        }
        HashMap<QName,ElementDeclaration> elements=getElementDeclarationsForScope(scopeClass.getName());
        if (elements == null) {
          elements=new HashMap<QName,ElementDeclaration>();
          this.elementDeclarations.put(scopeClass.getName(),elements);
        }
        elements.put(qname,declaration);
      }
      if (!helper.isBuiltInJavaType(type) && !classes.contains(type)) {
        classes.add(type);
      }
    }
  }
  if (classes.size() > 0) {
    return classes.toArray(new JavaClass[classes.size()]);
  }
 else {
    return new JavaClass[0];
  }
}

Fixed version (ground truth):
public JavaClass[] processObjectFactory(JavaClass objectFactoryClass,ArrayList<JavaClass> classes){
  Map<String,org.eclipse.persistence.jaxb.xmlmodel.XmlRegistry.XmlElementDecl> elemDecls=new HashMap<String,org.eclipse.persistence.jaxb.xmlmodel.XmlRegistry.XmlElementDecl>();
  org.eclipse.persistence.jaxb.xmlmodel.XmlRegistry xmlReg=xmlRegistries.get(objectFactoryClass.getQualifiedName());
  if (xmlReg != null) {
    for (    org.eclipse.persistence.jaxb.xmlmodel.XmlRegistry.XmlElementDecl xmlElementDecl : xmlReg.getXmlElementDecl()) {
      elemDecls.put(xmlElementDecl.getJavaMethod(),xmlElementDecl);
    }
  }
  Collection methods=objectFactoryClass.getDeclaredMethods();
  Iterator methodsIter=methods.iterator();
  NamespaceInfo namespaceInfo=getNamespaceInfoForPackage(objectFactoryClass);
  while (methodsIter.hasNext()) {
    JavaMethod next=(JavaMethod)methodsIter.next();
    if (next.getName().startsWith("String_Node_Str")) {
      JavaClass type=next.getReturnType();
      if (type.getName().equals("String_Node_Str")) {
        type=(JavaClass)next.getReturnType().getActualTypeArguments().toArray()[0];
      }
 else {
        this.factoryMethods.put(next.getReturnType().getRawName(),next);
      }
      org.eclipse.persistence.jaxb.xmlmodel.XmlRegistry.XmlElementDecl xmlEltDecl=elemDecls.get(next.getName());
      if (xmlEltDecl != null || helper.isAnnotationPresent(next,XmlElementDecl.class)) {
        QName qname;
        QName substitutionHead=null;
        String url;
        String localName;
        String defaultValue=null;
        Class scopeClass=javax.xml.bind.annotation.XmlElementDecl.GLOBAL.class;
        if (xmlEltDecl != null) {
          url=xmlEltDecl.getNamespace();
          localName=xmlEltDecl.getName();
          String scopeClassName=xmlEltDecl.getScope();
          if (!scopeClassName.equals("String_Node_Str")) {
            JavaClass jScopeClass=helper.getJavaClass(scopeClassName);
            if (jScopeClass != null) {
              scopeClass=helper.getClassForJavaClass(jScopeClass);
              if (scopeClass == null) {
                scopeClass=javax.xml.bind.annotation.XmlElementDecl.GLOBAL.class;
              }
            }
          }
          if (!xmlEltDecl.getSubstitutionHeadName().equals("String_Node_Str")) {
            String subHeadLocal=xmlEltDecl.getSubstitutionHeadName();
            String subHeadNamespace=xmlEltDecl.getSubstitutionHeadNamespace();
            if (subHeadNamespace.equals("String_Node_Str")) {
              subHeadNamespace=namespaceInfo.getNamespace();
            }
            substitutionHead=new QName(subHeadNamespace,subHeadLocal);
          }
          if (!(xmlEltDecl.getDefaultValue().length() == 1 && xmlEltDecl.getDefaultValue().startsWith("String_Node_Str"))) {
            defaultValue=xmlEltDecl.getDefaultValue();
          }
        }
 else {
          XmlElementDecl elementDecl=(XmlElementDecl)helper.getAnnotation(next,XmlElementDecl.class);
          url=elementDecl.namespace();
          localName=elementDecl.name();
          scopeClass=elementDecl.scope();
          if (!elementDecl.substitutionHeadName().equals("String_Node_Str")) {
            String subHeadLocal=elementDecl.substitutionHeadName();
            String subHeadNamespace=elementDecl.substitutionHeadNamespace();
            if (subHeadNamespace.equals("String_Node_Str")) {
              subHeadNamespace=namespaceInfo.getNamespace();
            }
            substitutionHead=new QName(subHeadNamespace,subHeadLocal);
          }
          if (!(elementDecl.defaultValue().length() == 1 && elementDecl.defaultValue().startsWith("String_Node_Str"))) {
            defaultValue=elementDecl.defaultValue();
          }
        }
        if ("String_Node_Str".equals(url)) {
          url=namespaceInfo.getNamespace();
        }
        qname=new QName(url,localName);
        boolean isList=false;
        if ("String_Node_Str".equals(type.getName())) {
          isList=true;
          if (type.hasActualTypeArguments()) {
            type=(JavaClass)type.getActualTypeArguments().toArray()[0];
          }
        }
        ElementDeclaration declaration=new ElementDeclaration(qname,type,type.getQualifiedName(),isList,scopeClass);
        if (substitutionHead != null) {
          declaration.setSubstitutionHead(substitutionHead);
        }
        if (defaultValue != null) {
          declaration.setDefaultValue(defaultValue);
        }
        if (helper.isAnnotationPresent(next,XmlJavaTypeAdapter.class)) {
          XmlJavaTypeAdapter typeAdapter=(XmlJavaTypeAdapter)helper.getAnnotation(next,XmlJavaTypeAdapter.class);
          Class typeAdapterClass=typeAdapter.value();
          declaration.setJavaTypeAdapterClass(typeAdapterClass);
          Class declJavaType=CompilerHelper.getTypeFromAdapterClass(typeAdapterClass);
          declaration.setJavaType(helper.getJavaClass(declJavaType));
          declaration.setAdaptedJavaType(type);
        }
        HashMap<QName,ElementDeclaration> elements=getElementDeclarationsForScope(scopeClass.getName());
        if (elements == null) {
          elements=new HashMap<QName,ElementDeclaration>();
          this.elementDeclarations.put(scopeClass.getName(),elements);
        }
        elements.put(qname,declaration);
      }
      if (!helper.isBuiltInJavaType(type) && !classes.contains(type)) {
        classes.add(type);
      }
    }
  }
  if (classes.size() > 0) {
    return classes.toArray(new JavaClass[classes.size()]);
  }
 else {
    return new JavaClass[0];
  }
}