Program: 65813
Project: 65813
Buggy source:
private SimpleType generateSimpleType(Type type){
  SDOType sdoType=(SDOType)type;
  SimpleType simpleType=new SimpleType();
  String xsdLocalName=sdoType.getXsdLocalName();
  if (xsdLocalName != null) {
    simpleType.setName(xsdLocalName);
  }
 else {
    simpleType.setName(sdoType.getName());
  }
  if ((sdoType.getAppInfoElements() != null) && (sdoType.getAppInfoElements().size() > 0)) {
    Annotation annotation=new Annotation();
    annotation.setAppInfo(sdoType.getAppInfoElements());
    simpleType.setAnnotation(annotation);
  }
  if ((xsdLocalName != null) && !(xsdLocalName.equals(sdoType.getName()))) {
    String sdoXmlPrefix=getPrefixForURI(SDOConstants.SDOXML_URL);
    QName qname=new QName(SDOConstants.SDOXML_URL,SDOConstants.SDOXML_NAME,sdoXmlPrefix);
    simpleType.getAttributesMap().put(qname,sdoType.getName());
  }
  if ((sdoType.getAliasNames() != null) && (sdoType.getAliasNames().size() > 0)) {
    String sdoXmlPrefix=getPrefixForURI(SDOConstants.SDOXML_URL);
    String aliasNamesString=buildAliasNameString(sdoType.getAliasNames());
    QName qname=new QName(SDOConstants.SDOXML_URL,SDOConstants.SDOXML_ALIASNAME,sdoXmlPrefix);
    simpleType.getAttributesMap().put(qname,aliasNamesString);
  }
  Object value=sdoType.get(SDOConstants.JAVA_CLASS_PROPERTY);
  if ((value != null) && value instanceof String) {
    String sdoJavaPrefix=getPrefixForURI(SDOConstants.SDOJAVA_URL);
    QName qname=new QName(SDOConstants.SDOJAVA_URL,SDOConstants.SDOJAVA_INSTANCECLASS,sdoJavaPrefix);
    simpleType.getAttributesMap().put(qname,value);
  }
  SDOType baseType=null;
  if ((sdoType.getBaseTypes() != null) && (sdoType.getBaseTypes().size() > 0) && ((SDOType)sdoType.getBaseTypes().get(0) != null)) {
    baseType=(SDOType)sdoType.getBaseTypes().get(0);
  }
  if (baseType != null) {
    Restriction restriction=new Restriction();
    addTypeToListIfNeeded(sdoType,baseType);
    QName schemaType=((SDOTypeHelper)aHelperContext.getTypeHelper()).getXSDTypeFromSDOType(baseType);
    if (schemaType != null) {
      String prefix=getPrefixStringForURI(schemaType.getNamespaceURI());
      restriction.setBaseType(prefix + schemaType.getLocalPart());
    }
 else {
      String prefix=getPrefixStringForURI(baseType.getURI());
      restriction.setBaseType(prefix + baseType.getName());
    }
    simpleType.setRestriction(restriction);
  }
  return simpleType;
}

Fixed version (ground truth):
private SimpleType generateSimpleType(Type type){
  SDOType sdoType=(SDOType)type;
  SimpleType simpleType=new SimpleType();
  String xsdLocalName=sdoType.getXsdLocalName();
  if (xsdLocalName != null) {
    simpleType.setName(xsdLocalName);
  }
 else {
    simpleType.setName(sdoType.getName());
  }
  if ((sdoType.getAppInfoElements() != null) && (sdoType.getAppInfoElements().size() > 0)) {
    Annotation annotation=new Annotation();
    annotation.setAppInfo(sdoType.getAppInfoElements());
    simpleType.setAnnotation(annotation);
  }
  if ((xsdLocalName != null) && !(xsdLocalName.equals(sdoType.getName()))) {
    String sdoXmlPrefix=getPrefixForURI(SDOConstants.SDOXML_URL);
    QName qname=new QName(SDOConstants.SDOXML_URL,SDOConstants.SDOXML_NAME,sdoXmlPrefix);
    simpleType.getAttributesMap().put(qname,sdoType.getName());
  }
  if ((sdoType.getAliasNames() != null) && (sdoType.getAliasNames().size() > 0)) {
    String sdoXmlPrefix=getPrefixForURI(SDOConstants.SDOXML_URL);
    String aliasNamesString=buildAliasNameString(sdoType.getAliasNames());
    QName qname=new QName(SDOConstants.SDOXML_URL,SDOConstants.SDOXML_ALIASNAME,sdoXmlPrefix);
    simpleType.getAttributesMap().put(qname,aliasNamesString);
  }
  Object value=sdoType.get(SDOConstants.JAVA_CLASS_PROPERTY);
  if ((value != null) && value instanceof String) {
    String sdoJavaPrefix=getPrefixForURI(SDOConstants.SDOJAVA_URL);
    QName qname=new QName(SDOConstants.SDOJAVA_URL,SDOConstants.SDOJAVA_INSTANCECLASS,sdoJavaPrefix);
    simpleType.getAttributesMap().put(qname,value);
  }
  SDOType baseType=null;
  if (sdoType.isSubType()) {
    baseType=(SDOType)sdoType.getBaseTypes().get(0);
  }
  if (baseType != null) {
    Restriction restriction=new Restriction();
    addTypeToListIfNeeded(sdoType,baseType);
    QName schemaType=((SDOTypeHelper)aHelperContext.getTypeHelper()).getXSDTypeFromSDOType(baseType);
    if (schemaType != null) {
      String prefix=getPrefixStringForURI(schemaType.getNamespaceURI());
      restriction.setBaseType(prefix + schemaType.getLocalPart());
    }
 else {
      String prefix=getPrefixStringForURI(baseType.getURI());
      restriction.setBaseType(prefix + baseType.getName());
    }
    simpleType.setRestriction(restriction);
  }
  return simpleType;
}