Program: 66737
Project: 66737
Buggy source:
public void initTypeToSchemaType(){
  this.typeMappingInfoToSchemaType=new HashMap<TypeMappingInfo,QName>();
  Iterator descriptors=xmlContext.getSession(0).getProject().getOrderedDescriptors().iterator();
  HashMap defaults=XMLConversionManager.getDefaultJavaTypes();
  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=null;
        if (nextType instanceof Class) {
          name=this.generator.getAnnotationsProcessor().getUserDefinedSchemaTypes().get(((Class)nextType).getName());
        }
        if (name == null) {
          if (nextType == ClassConstants.ABYTE || nextType == ClassConstants.APBYTE) {
            name=XMLConstants.BASE_64_BINARY_QNAME;
          }
 else {
            name=(QName)defaults.get(next);
          }
        }
        if (name != null) {
          this.typeMappingInfoToSchemaType.put(next,name);
        }
      }
    }
  }
}

Fixed version (ground truth):
public void initTypeToSchemaType(){
  this.typeToSchemaType=new HashMap<Type,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;
      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)) {
                type=entry.getKey().getType();
                break;
              }
            }
          }
        }
        if (type == null) {
          type=javaClass;
        }
      }
 else {
        type=javaClass;
      }
      this.typeToSchemaType.put(type,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.typeToSchemaType.put(nextType,name);
        }
      }
    }
  }
}