Program: 67716
Project: 67716
Buggy source:
public JavaClass[] processObjectFactory(JavaClass objectFactoryClass,ArrayList<JavaClass> classes){
  Collection methods=objectFactoryClass.getMethods();
  Iterator methodsIter=methods.iterator();
  NamespaceInfo namespaceInfo=getNamespaceInfoForPackage(objectFactoryClass.getPackage());
  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);
      }
      if (helper.isAnnotationPresent(next,XmlElementDecl.class)) {
        XmlElementDecl elementDecl=(XmlElementDecl)helper.getAnnotation(next,XmlElementDecl.class);
        String url=elementDecl.namespace();
        if ("String_Node_Str".equals(url)) {
          url=namespaceInfo.getNamespace();
        }
        String localName=elementDecl.name();
        QName qname=new QName(url,localName);
        if (this.globalElements == null) {
          globalElements=new HashMap<QName,ElementDeclaration>();
        }
        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);
        if (!elementDecl.substitutionHeadName().equals("String_Node_Str")) {
          String subHeadLocal=elementDecl.substitutionHeadName();
          String subHeadNamespace=elementDecl.substitutionHeadNamespace();
          if (subHeadNamespace.equals("String_Node_Str")) {
            subHeadNamespace=namespaceInfo.getNamespace();
          }
          declaration.setSubstitutionHead(new QName(subHeadNamespace,subHeadLocal));
        }
        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=null;
          for (int i=0; i < tacMethods.length; i++) {
            Method method=tacMethods[i];
            if (method.getName().equals("String_Node_Str")) {
              declJavaType=method.getReturnType();
              break;
            }
          }
          declaration.setJavaType(helper.getJavaClass(declJavaType));
          declaration.setAdaptedJavaType(type);
        }
        globalElements.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){
  Collection methods=objectFactoryClass.getMethods();
  Iterator methodsIter=methods.iterator();
  NamespaceInfo namespaceInfo=getNamespaceInfoForPackage(objectFactoryClass.getPackage());
  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);
      }
      if (helper.isAnnotationPresent(next,XmlElementDecl.class)) {
        XmlElementDecl elementDecl=(XmlElementDecl)helper.getAnnotation(next,XmlElementDecl.class);
        String url=elementDecl.namespace();
        if ("String_Node_Str".equals(url)) {
          url=namespaceInfo.getNamespace();
        }
        String localName=elementDecl.name();
        QName qname=new QName(url,localName);
        if (this.globalElements == null) {
          globalElements=new HashMap<QName,ElementDeclaration>();
        }
        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,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();
          }
          declaration.setSubstitutionHead(new QName(subHeadNamespace,subHeadLocal));
        }
        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=null;
          for (int i=0; i < tacMethods.length; i++) {
            Method method=tacMethods[i];
            if (method.getName().equals("String_Node_Str")) {
              declJavaType=method.getReturnType();
              break;
            }
          }
          declaration.setJavaType(helper.getJavaClass(declJavaType));
          declaration.setAdaptedJavaType(type);
        }
        globalElements.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];
  }
}