Program: 66008
Project: 66008
Buggy source:
/** 
 * Return the type name for an Element based on a given property.  
 * @param property the Property that the type name will be based on
 * @param schema the schema currently being built
 * @param javaClass the given Property's 'actual' type
 * @param element the element being generated for the given Property
 * @return a type name based on the given Property, or null if not obtainable
 */
private String getTypeNameForElement(Property property,Schema schema,JavaClass javaClass,Element element){
  String typeName=null;
  if (property.isXmlId()) {
    typeName=XMLConstants.SCHEMA_PREFIX + COLON + ID;
  }
 else   if (property.isXmlIdRef()) {
    typeName=XMLConstants.SCHEMA_PREFIX + COLON + IDREF;
  }
 else {
    TypeInfo info=(TypeInfo)typeInfo.get(javaClass.getQualifiedName());
    if (info != null) {
      if (info.isComplexType()) {
        typeName=info.getComplexType().getName();
      }
 else       if (info.getSimpleType() != null) {
        typeName=info.getSimpleType().getName();
      }
 else {
        typeName=info.getSchemaTypeName();
      }
      if (typeName == null) {
        if (!info.hasRootElement()) {
          if (info.isComplexType()) {
            element.setComplexType(info.getComplexType());
          }
 else {
            element.setSimpleType(info.getSimpleType());
          }
        }
      }
 else {
        if (addImportIfRequired(schema,info.getSchema(),info.getClassNamespace())) {
          String prefix=schema.getNamespaceResolver().resolveNamespaceURI(info.getClassNamespace());
          if (prefix != null && (!typeName.equals(EMPTY_STRING))) {
            typeName=prefix + COLON + typeName;
          }
        }
      }
    }
 else     if (!property.isMap()) {
      typeName=getTypeName(property,javaClass,schema);
    }
    if (typeName != null && !typeName.contains(COLON)) {
      String prefix;
      if (info.getClassNamespace().equals(XMLConstants.SCHEMA_URL)) {
        prefix=XMLConstants.SCHEMA_PREFIX;
      }
 else {
        prefix=getPrefixForNamespace(info.getSchema().getTargetNamespace(),schema.getNamespaceResolver());
      }
      if (prefix != null) {
        typeName=prefix + COLON + typeName;
      }
    }
  }
  return typeName;
}

Fixed version (ground truth):
/** 
 * Return the type name for an Element based on a given property.  
 * @param property the Property that the type name will be based on
 * @param schema the schema currently being built
 * @param javaClass the given Property's 'actual' type
 * @param element the element being generated for the given Property
 * @return a type name based on the given Property, or null if not obtainable
 */
private String getTypeNameForElement(Property property,Schema schema,JavaClass javaClass,Element element){
  String typeName=null;
  if (property.isXmlId()) {
    typeName=XMLConstants.SCHEMA_PREFIX + COLON + ID;
  }
 else   if (property.isXmlIdRef()) {
    typeName=XMLConstants.SCHEMA_PREFIX + COLON + IDREF;
  }
 else {
    TypeInfo info=(TypeInfo)typeInfo.get(javaClass.getQualifiedName());
    if (info != null) {
      if (info.isComplexType()) {
        typeName=info.getComplexType().getName();
      }
 else       if (info.getSimpleType() != null) {
        typeName=info.getSimpleType().getName();
      }
 else {
        typeName=info.getSchemaTypeName();
      }
      if (typeName == null) {
        if (!info.hasRootElement()) {
          if (info.isComplexType()) {
            element.setComplexType(info.getComplexType());
          }
 else {
            element.setSimpleType(info.getSimpleType());
          }
        }
      }
 else {
        if (addImportIfRequired(schema,info.getSchema(),info.getClassNamespace())) {
          String prefix=schema.getNamespaceResolver().resolveNamespaceURI(info.getClassNamespace());
          if (prefix != null && (!typeName.equals(EMPTY_STRING))) {
            typeName=prefix + COLON + typeName;
          }
        }
      }
    }
 else     if (!property.isMap()) {
      typeName=getTypeName(property,javaClass,schema);
    }
    if (typeName != null && !typeName.contains(COLON)) {
      String prefix;
      if (info.getClassNamespace().equals(XMLConstants.SCHEMA_URL)) {
        prefix=XMLConstants.SCHEMA_PREFIX;
      }
 else {
        prefix=getPrefixForNamespace(info.getClassNamespace(),schema.getNamespaceResolver());
      }
      if (prefix != null) {
        typeName=prefix + COLON + typeName;
      }
    }
  }
  return typeName;
}