Program: 67752
Project: 67752
Buggy source:
public void updateGlobalElements(ArrayList<JavaClass> classesToProcess){
  for (  JavaClass javaClass : classesToProcess) {
    if (helper.isAnnotationPresent(javaClass,XmlRootElement.class)) {
      XmlRootElement rootElemAnnotation=(XmlRootElement)helper.getAnnotation(javaClass,XmlRootElement.class);
      NamespaceInfo namespaceInfo;
      JavaPackage pack=javaClass.getPackage();
      namespaceInfo=getNamespaceInfoForPackage(pack);
      String elementName=rootElemAnnotation.name();
      if (elementName.equals("String_Node_Str") || elementName.equals("String_Node_Str")) {
        if (javaClass.getName().indexOf("String_Node_Str") != -1) {
          elementName=Introspector.decapitalize(javaClass.getName().substring(javaClass.getName().lastIndexOf('$') + 1));
        }
 else {
          elementName=Introspector.decapitalize(javaClass.getName().substring(javaClass.getName().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;
          }
        }
      }
      String rootNamespace=rootElemAnnotation.namespace();
      QName rootElemName=null;
      if (rootNamespace.equals("String_Node_Str")) {
        if (namespaceInfo == null) {
          rootElemName=new QName(elementName);
        }
 else {
          rootElemName=new QName(namespaceInfo.getNamespace(),elementName);
        }
      }
 else {
        rootElemName=new QName(rootNamespace,elementName);
      }
      ElementDeclaration declaration=new ElementDeclaration(rootElemName,javaClass,javaClass.getRawName(),false);
      declaration.setIsXmlRootElement(true);
      if (this.globalElements == null) {
        globalElements=new HashMap<QName,ElementDeclaration>();
      }
      this.globalElements.put(rootElemName,declaration);
    }
  }
  if (this.globalElements == null) {
    return;
  }
  Iterator<QName> elementQnames=this.globalElements.keySet().iterator();
  while (elementQnames.hasNext()) {
    QName next=elementQnames.next();
    ElementDeclaration nextDeclaration=this.globalElements.get(next);
    if (nextDeclaration.getSubstitutionHead() != null) {
      ElementDeclaration rootDeclaration=this.globalElements.get(nextDeclaration.getSubstitutionHead());
      rootDeclaration.addSubstitutableElement(nextDeclaration);
    }
  }
}

Fixed version (ground truth):
public void updateGlobalElements(ArrayList<JavaClass> classesToProcess){
  for (  JavaClass javaClass : classesToProcess) {
    if (helper.isAnnotationPresent(javaClass,XmlRootElement.class)) {
      XmlRootElement rootElemAnnotation=(XmlRootElement)helper.getAnnotation(javaClass,XmlRootElement.class);
      NamespaceInfo namespaceInfo;
      JavaPackage pack=javaClass.getPackage();
      namespaceInfo=getNamespaceInfoForPackage(pack);
      String elementName=rootElemAnnotation.name();
      if (elementName.equals("String_Node_Str") || elementName.equals("String_Node_Str")) {
        if (javaClass.getName().indexOf("String_Node_Str") != -1) {
          elementName=Introspector.decapitalize(javaClass.getName().substring(javaClass.getName().lastIndexOf('$') + 1));
        }
 else {
          elementName=Introspector.decapitalize(javaClass.getName().substring(javaClass.getName().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;
          }
        }
      }
      String rootNamespace=rootElemAnnotation.namespace();
      QName rootElemName=null;
      if (rootNamespace.equals("String_Node_Str")) {
        if (namespaceInfo == null) {
          rootElemName=new QName(elementName);
        }
 else {
          rootElemName=new QName(namespaceInfo.getNamespace(),elementName);
        }
      }
 else {
        rootElemName=new QName(rootNamespace,elementName);
      }
      ElementDeclaration declaration=new ElementDeclaration(rootElemName,javaClass,javaClass.getQualifiedName(),false);
      declaration.setIsXmlRootElement(true);
      if (this.globalElements == null) {
        globalElements=new HashMap<QName,ElementDeclaration>();
      }
      this.globalElements.put(rootElemName,declaration);
      this.xmlRootElements.put(javaClass.getQualifiedName(),declaration);
    }
  }
  if (this.globalElements == null) {
    return;
  }
  Iterator<QName> elementQnames=this.globalElements.keySet().iterator();
  while (elementQnames.hasNext()) {
    QName next=elementQnames.next();
    ElementDeclaration nextDeclaration=this.globalElements.get(next);
    if (nextDeclaration.getSubstitutionHead() != null) {
      ElementDeclaration rootDeclaration=this.globalElements.get(nextDeclaration.getSubstitutionHead());
      rootDeclaration.addSubstitutableElement(nextDeclaration);
    }
  }
}