Program: 66712
Project: 66712
Buggy source:
public void initTypeMappingInfoToSchemaType(){
  this.typeMappingInfoToSchemaType=new HashMap<TypeMappingInfo,QName>();
  if (typeToTypeMappingInfo != null && typeToTypeMappingInfo.size() > 0) {
    return;
  }
  Iterator descriptors=xmlContext.getSession(0).getProject().getOrderedDescriptors().iterator();
  while (descriptors.hasNext()) {
    XMLDescriptor next=(XMLDescriptor)descriptors.next();
    Class javaClass=next.getJavaClass();
    if (next.getSchemaReference() != null) {
      QName schemaType=next.getSchemaReference().getSchemaContextAsQName(next.getNamespaceResolver());
      Type type=null;
      TypeMappingInfo tmi=null;
      if (generator != null) {
        type=generator.getAnnotationsProcessor().getGeneratedClassesToCollectionClasses().get(javaClass);
        if (type == null) {
          JavaClass arrayClass=(JavaClass)generator.getAnnotationsProcessor().getGeneratedClassesToArrayClasses().get(javaClass);
          if (arrayClass != null) {
            String arrayClassName=arrayClass.getName();
            try {
              type=PrivilegedAccessHelper.getClassForName(arrayClassName);
            }
 catch (            Exception ex) {
            }
          }
          if (type == null && getTypeMappingInfoToGeneratedType() != null) {
            Iterator<Map.Entry<TypeMappingInfo,Class>> iter=getTypeMappingInfoToGeneratedType().entrySet().iterator();
            while (iter.hasNext()) {
              Map.Entry<TypeMappingInfo,Class> entry=iter.next();
              if (entry.getValue().equals(javaClass)) {
                tmi=entry.getKey();
                break;
              }
            }
          }
        }
        if (type == null) {
          type=javaClass;
        }
      }
 else {
        type=javaClass;
      }
      if (tmi == null && type != null) {
        tmi=new TypeMappingInfo();
        tmi.setType(type);
      }
      this.typeMappingInfoToSchemaType.put(tmi,schemaType);
    }
  }
  if (boundTypes != null) {
    for (    TypeMappingInfo next : this.boundTypes) {
      if (this.typeToSchemaType.get(next) == null) {
        Type nextType=next.getType();
        QName name=getSchemaTypeForTypeMappingInfo(nextType);
        if (name != null) {
          this.typeMappingInfoToSchemaType.put(next,name);
        }
      }
    }
  }
}

Fixed version (ground truth):
public void initTypeMappingInfoToSchemaType(){
  this.typeMappingInfoToSchemaType=new HashMap<TypeMappingInfo,QName>();
  if (typeToTypeMappingInfo != null && typeToTypeMappingInfo.size() > 0) {
    return;
  }
  Iterator descriptors=xmlContext.getSession(0).getProject().getOrderedDescriptors().iterator();
  while (descriptors.hasNext()) {
    XMLDescriptor next=(XMLDescriptor)descriptors.next();
    Class javaClass=next.getJavaClass();
    if (next.getSchemaReference() != null) {
      QName schemaType=next.getSchemaReference().getSchemaContextAsQName(next.getNamespaceResolver());
      Type type=null;
      TypeMappingInfo tmi=null;
      if (generator != null) {
        type=generator.getAnnotationsProcessor().getGeneratedClassesToCollectionClasses().get(javaClass);
        if (type == null) {
          JavaClass arrayClass=(JavaClass)generator.getAnnotationsProcessor().getGeneratedClassesToArrayClasses().get(javaClass);
          if (arrayClass != null) {
            String arrayClassName=arrayClass.getName();
            try {
              type=PrivilegedAccessHelper.getClassForName(arrayClassName);
            }
 catch (            Exception ex) {
            }
          }
          if (type == null && getTypeMappingInfoToGeneratedType() != null) {
            Iterator<Map.Entry<TypeMappingInfo,Class>> iter=getTypeMappingInfoToGeneratedType().entrySet().iterator();
            while (iter.hasNext()) {
              Map.Entry<TypeMappingInfo,Class> entry=iter.next();
              if (entry.getValue().equals(javaClass)) {
                tmi=entry.getKey();
                break;
              }
            }
          }
        }
        if (type == null) {
          type=javaClass;
        }
      }
 else {
        type=javaClass;
      }
      if (tmi == null && type != null) {
        tmi=new TypeMappingInfo();
        tmi.setType(type);
      }
      this.typeMappingInfoToSchemaType.put(tmi,schemaType);
    }
  }
  if (boundTypes != null) {
    for (    TypeMappingInfo next : this.boundTypes) {
      if (this.typeMappingInfoToSchemaType.get(next) == null) {
        Type nextType=next.getType();
        QName name=getSchemaTypeForTypeMappingInfo(nextType);
        if (name != null) {
          this.typeMappingInfoToSchemaType.put(next,name);
        }
      }
    }
  }
}