Program: 66741
Project: 66741
Buggy source:
/** 
 * Process XmlBindings on a per package basis for a given AnnotationsPorcessor instance.
 * @param annotationsProcessor
 */
public void processXML(AnnotationsProcessor annotationsProcessor,JavaModelInput jModelInput,TypeMappingInfo[] typeMappingInfos,JavaClass[] originalJavaClasses){
  this.jModelInput=jModelInput;
  this.aProcessor=annotationsProcessor;
  annotationsProcessor.init(originalJavaClasses,typeMappingInfos);
  Map<String,ArrayList<JavaClass>> pkgToClassMap=buildPackageToJavaClassMap();
  XmlBindings xmlBindings;
  for (  String packageName : xmlBindingMap.keySet()) {
    ArrayList classesToProcess=pkgToClassMap.get(packageName);
    if (classesToProcess == null) {
      getLogger().logWarning("String_Node_Str",new Object[]{packageName});
      continue;
    }
    xmlBindings=xmlBindingMap.get(packageName);
    NamespaceInfo nsInfo=processXmlSchema(xmlBindings,packageName);
    if (nsInfo != null) {
      annotationsProcessor.addPackageToNamespaceMapping(packageName,nsInfo);
    }
    JavaClass[] javaClasses=(JavaClass[])classesToProcess.toArray(new JavaClass[classesToProcess.size()]);
    Map<String,TypeInfo> typeInfoMap=annotationsProcessor.preBuildTypeInfo(javaClasses);
    nsInfo=annotationsProcessor.getPackageToNamespaceMappings().get(packageName);
    JavaTypes jTypes=xmlBindings.getJavaTypes();
    if (jTypes != null) {
      for (      JavaType javaType : jTypes.getJavaType()) {
        TypeInfo info=typeInfoMap.get(javaType.getName());
        if (javaType.getXmlJavaTypeAdapter() != null) {
          info.setXmlJavaTypeAdapter(javaType.getXmlJavaTypeAdapter());
        }
        if (javaType.isSetXmlAccessorOrder()) {
          info.setXmlAccessOrder(javaType.getXmlAccessorOrder());
        }
 else         if (!info.isSetXmlAccessOrder()) {
          if (xmlBindings.isSetXmlAccessorOrder()) {
            info.setXmlAccessOrder(xmlBindings.getXmlAccessorOrder());
          }
 else {
            info.setXmlAccessOrder(nsInfo.getAccessOrder());
          }
        }
        if (javaType.isSetXmlAccessorType()) {
          info.setXmlAccessType(javaType.getXmlAccessorType());
        }
 else         if (!info.isSetXmlAccessType()) {
          if (xmlBindings.isSetXmlAccessorType()) {
            info.setXmlAccessType(xmlBindings.getXmlAccessorType());
          }
 else {
            info.setXmlAccessType(nsInfo.getAccessType());
          }
        }
        if (javaType.isSetXmlTransient()) {
          info.setXmlTransient(javaType.isXmlTransient());
        }
        if (javaType.getXmlRootElement() != null) {
          info.setXmlRootElement(javaType.getXmlRootElement());
        }
        if (javaType.getXmlSeeAlso() != null && javaType.getXmlSeeAlso().size() > 0) {
          info.setXmlSeeAlso(javaType.getXmlSeeAlso());
        }
        if (javaType.getXmlType() != null) {
          info.setXmlType(javaType.getXmlType());
        }
        if (javaType.getXmlCustomizer() != null) {
          info.setXmlCustomizer(javaType.getXmlCustomizer());
        }
      }
    }
    if (xmlBindings.getXmlJavaTypeAdapters() != null) {
      Map<String,TypeInfo> typeInfos=aProcessor.getTypeInfosForPackage(packageName);
      for (      TypeInfo tInfo : typeInfos.values()) {
        List<XmlJavaTypeAdapter> adapters=xmlBindings.getXmlJavaTypeAdapters().getXmlJavaTypeAdapter();
        for (        XmlJavaTypeAdapter xja : adapters) {
          JavaClass adapterClass=jModelInput.getJavaModel().getClass(xja.getValue());
          JavaClass boundType=jModelInput.getJavaModel().getClass(xja.getType());
          if (boundType != null) {
            tInfo.addPackageLevelAdapterClass(adapterClass,boundType);
          }
        }
      }
    }
    javaClasses=annotationsProcessor.postBuildTypeInfo(javaClasses);
    annotationsProcessor.processJavaClasses(javaClasses);
    Map<String,TypeInfo> typeInfosForPackage=annotationsProcessor.getTypeInfosForPackage(packageName);
    jTypes=xmlBindings.getJavaTypes();
    if (jTypes != null) {
      for (      JavaType javaType : jTypes.getJavaType()) {
        TypeInfo typeInfo=typeInfosForPackage.get(javaType.getName());
        if (javaType != null) {
          processJavaType(javaType,typeInfo,nsInfo);
        }
      }
    }
    pkgToClassMap.remove(packageName);
  }
  Iterator<ArrayList<JavaClass>> classIt=pkgToClassMap.values().iterator();
  while (classIt.hasNext()) {
    ArrayList<JavaClass> jClassList=classIt.next();
    JavaClass[] jClassArray=(JavaClass[])jClassList.toArray(new JavaClass[jClassList.size()]);
    annotationsProcessor.buildNewTypeInfo(jClassArray);
    annotationsProcessor.processJavaClasses(jClassArray);
  }
  Map<String,TypeInfo> typeInfos=(Map<String,TypeInfo>)aProcessor.getTypeInfo().clone();
  for (  String key : typeInfos.keySet()) {
    JavaClass[] jClassArray;
    TypeInfo tInfo=typeInfos.get(key);
    for (    Property prop : tInfo.getPropertyList()) {
      if (prop.isSetXmlJavaTypeAdapter()) {
        jClassArray=new JavaClass[]{prop.getActualType()};
        aProcessor.buildNewTypeInfo(jClassArray);
      }
    }
  }
  aProcessor.finalizeProperties();
}

Fixed version (ground truth):
/** 
 * Process XmlBindings on a per package basis for a given AnnotationsPorcessor instance.
 * @param annotationsProcessor
 */
public void processXML(AnnotationsProcessor annotationsProcessor,JavaModelInput jModelInput,TypeMappingInfo[] typeMappingInfos,JavaClass[] originalJavaClasses){
  this.jModelInput=jModelInput;
  this.aProcessor=annotationsProcessor;
  annotationsProcessor.init(originalJavaClasses,typeMappingInfos);
  Map<String,ArrayList<JavaClass>> pkgToClassMap=buildPackageToJavaClassMap();
  XmlBindings xmlBindings;
  for (  String packageName : xmlBindingMap.keySet()) {
    ArrayList classesToProcess=pkgToClassMap.get(packageName);
    if (classesToProcess == null) {
      getLogger().logWarning("String_Node_Str",new Object[]{packageName});
      continue;
    }
    xmlBindings=xmlBindingMap.get(packageName);
    NamespaceInfo nsInfo=processXmlSchema(xmlBindings,packageName);
    if (nsInfo != null) {
      annotationsProcessor.addPackageToNamespaceMapping(packageName,nsInfo);
    }
    JavaClass[] javaClasses=(JavaClass[])classesToProcess.toArray(new JavaClass[classesToProcess.size()]);
    Map<String,TypeInfo> typeInfoMap=annotationsProcessor.preBuildTypeInfo(javaClasses);
    nsInfo=annotationsProcessor.getPackageToNamespaceMappings().get(packageName);
    JavaTypes jTypes=xmlBindings.getJavaTypes();
    if (jTypes != null) {
      for (      JavaType javaType : jTypes.getJavaType()) {
        TypeInfo info=typeInfoMap.get(javaType.getName());
        if (javaType.getXmlJavaTypeAdapter() != null) {
          info.setXmlJavaTypeAdapter(javaType.getXmlJavaTypeAdapter());
        }
        if (javaType.isSetXmlAccessorOrder()) {
          info.setXmlAccessOrder(javaType.getXmlAccessorOrder());
        }
 else         if (!info.isSetXmlAccessOrder()) {
          if (xmlBindings.isSetXmlAccessorOrder()) {
            info.setXmlAccessOrder(xmlBindings.getXmlAccessorOrder());
          }
 else {
            info.setXmlAccessOrder(nsInfo.getAccessOrder());
          }
        }
        if (javaType.isSetXmlAccessorType()) {
          info.setXmlAccessType(javaType.getXmlAccessorType());
        }
 else         if (!info.isSetXmlAccessType()) {
          if (xmlBindings.isSetXmlAccessorType()) {
            info.setXmlAccessType(xmlBindings.getXmlAccessorType());
          }
 else {
            info.setXmlAccessType(nsInfo.getAccessType());
          }
        }
        if (javaType.isSetXmlTransient()) {
          info.setXmlTransient(javaType.isXmlTransient());
        }
        if (javaType.getXmlRootElement() != null) {
          info.setXmlRootElement(javaType.getXmlRootElement());
        }
        if (javaType.getXmlSeeAlso() != null && javaType.getXmlSeeAlso().size() > 0) {
          info.setXmlSeeAlso(javaType.getXmlSeeAlso());
        }
        if (javaType.getXmlType() != null) {
          info.setXmlType(javaType.getXmlType());
        }
        if (javaType.getXmlCustomizer() != null) {
          info.setXmlCustomizer(javaType.getXmlCustomizer());
        }
      }
    }
    if (xmlBindings.getXmlJavaTypeAdapters() != null) {
      Map<String,TypeInfo> typeInfos=aProcessor.getTypeInfosForPackage(packageName);
      for (      TypeInfo tInfo : typeInfos.values()) {
        List<XmlJavaTypeAdapter> adapters=xmlBindings.getXmlJavaTypeAdapters().getXmlJavaTypeAdapter();
        for (        XmlJavaTypeAdapter xja : adapters) {
          JavaClass adapterClass=jModelInput.getJavaModel().getClass(xja.getValue());
          JavaClass boundType=jModelInput.getJavaModel().getClass(xja.getType());
          if (boundType != null) {
            tInfo.addPackageLevelAdapterClass(adapterClass,boundType);
          }
        }
      }
    }
    javaClasses=annotationsProcessor.postBuildTypeInfo(javaClasses);
    annotationsProcessor.processJavaClasses(javaClasses);
    Map<String,TypeInfo> typeInfosForPackage=annotationsProcessor.getTypeInfosForPackage(packageName);
    jTypes=xmlBindings.getJavaTypes();
    if (jTypes != null) {
      for (      JavaType javaType : jTypes.getJavaType()) {
        TypeInfo typeInfo=typeInfosForPackage.get(javaType.getName());
        if (javaType != null) {
          processJavaType(javaType,typeInfo,nsInfo);
        }
      }
    }
    pkgToClassMap.remove(packageName);
  }
  Iterator<ArrayList<JavaClass>> classIt=pkgToClassMap.values().iterator();
  while (classIt.hasNext()) {
    ArrayList<JavaClass> jClassList=classIt.next();
    JavaClass[] jClassArray=(JavaClass[])jClassList.toArray(new JavaClass[jClassList.size()]);
    annotationsProcessor.buildNewTypeInfo(jClassArray);
    annotationsProcessor.processJavaClasses(jClassArray);
  }
  Map<String,TypeInfo> typeInfos=(Map<String,TypeInfo>)aProcessor.getTypeInfo().clone();
  for (  String key : typeInfos.keySet()) {
    JavaClass[] jClassArray;
    TypeInfo tInfo=typeInfos.get(key);
    for (    Property prop : tInfo.getPropertyList()) {
      if (prop.isSetXmlJavaTypeAdapter()) {
        jClassArray=new JavaClass[]{prop.getActualType()};
        aProcessor.buildNewTypeInfo(jClassArray);
      }
    }
  }
  aProcessor.finalizeProperties();
  aProcessor.createElementsForTypeMappingInfo();
}