Program: 65812
Project: 65812
Buggy source:
private ComplexType generateComplexType(Type type){
  SDOType sdoType=(SDOType)type;
  ComplexType complexType=new ComplexType();
  String xsdLocalName=sdoType.getXsdLocalName();
  if (xsdLocalName != null) {
    complexType.setName(xsdLocalName);
  }
 else {
    complexType.setName(sdoType.getName());
  }
  if ((xsdLocalName != null) && !(xsdLocalName.equals(sdoType.getName()))) {
    String sdoXmlPrefix=getPrefixForURI(SDOConstants.SDOXML_URL);
    QName qname=new QName(SDOConstants.SDOXML_URL,SDOConstants.SDOXML_NAME,sdoXmlPrefix);
    complexType.getAttributesMap().put(qname,sdoType.getName());
  }
  complexType.setAbstractValue(sdoType.isAbstract());
  if ((sdoType.getAppInfoElements() != null) && (sdoType.getAppInfoElements().size() > 0)) {
    Annotation annotation=new Annotation();
    annotation.setAppInfo(sdoType.getAppInfoElements());
    complexType.setAnnotation(annotation);
  }
  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);
    complexType.getAttributesMap().put(qname,aliasNamesString);
  }
  complexType.setMixed(sdoType.isSequenced());
  Type baseType=null;
  if ((sdoType.getBaseTypes() != null) && (sdoType.getBaseTypes().size() > 0) && ((Type)sdoType.getBaseTypes().get(0) != null)) {
    baseType=(Type)sdoType.getBaseTypes().get(0);
  }
  if (baseType != null) {
    addTypeToListIfNeeded(sdoType,baseType);
    Extension extension=new Extension();
    QName schemaType=((SDOTypeHelper)aHelperContext.getTypeHelper()).getXSDTypeFromSDOType(baseType);
    if (schemaType != null) {
      extension.setBaseType(getPrefixStringForURI(schemaType.getNamespaceURI()) + schemaType.getLocalPart());
    }
 else     if ((baseType.getURI() == null) || (baseType.getURI().equalsIgnoreCase(generatedSchema.getTargetNamespace()))) {
      extension.setBaseType(baseType.getName());
    }
 else {
      extension.setBaseType(getPrefixStringForURI(baseType.getURI()) + baseType.getName());
    }
    buildElementsAndAttributes(extension,sdoType);
    ComplexContent complexContent=new ComplexContent();
    complexContent.setExtension(extension);
    complexType.setComplexContent(complexContent);
    return complexType;
  }
  buildElementsAndAttributes(complexType,sdoType);
  return complexType;
}

Fixed version (ground truth):
private ComplexType generateComplexType(Type type){
  SDOType sdoType=(SDOType)type;
  ComplexType complexType=new ComplexType();
  String xsdLocalName=sdoType.getXsdLocalName();
  if (xsdLocalName != null) {
    complexType.setName(xsdLocalName);
  }
 else {
    complexType.setName(sdoType.getName());
  }
  if ((xsdLocalName != null) && !(xsdLocalName.equals(sdoType.getName()))) {
    String sdoXmlPrefix=getPrefixForURI(SDOConstants.SDOXML_URL);
    QName qname=new QName(SDOConstants.SDOXML_URL,SDOConstants.SDOXML_NAME,sdoXmlPrefix);
    complexType.getAttributesMap().put(qname,sdoType.getName());
  }
  complexType.setAbstractValue(sdoType.isAbstract());
  if ((sdoType.getAppInfoElements() != null) && (sdoType.getAppInfoElements().size() > 0)) {
    Annotation annotation=new Annotation();
    annotation.setAppInfo(sdoType.getAppInfoElements());
    complexType.setAnnotation(annotation);
  }
  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);
    complexType.getAttributesMap().put(qname,aliasNamesString);
  }
  complexType.setMixed(sdoType.isSequenced());
  Type baseType=null;
  if (sdoType.isSubType()) {
    baseType=(Type)sdoType.getBaseTypes().get(0);
  }
  if (baseType != null) {
    addTypeToListIfNeeded(sdoType,baseType);
    Extension extension=new Extension();
    QName schemaType=((SDOTypeHelper)aHelperContext.getTypeHelper()).getXSDTypeFromSDOType(baseType);
    if (schemaType != null) {
      extension.setBaseType(getPrefixStringForURI(schemaType.getNamespaceURI()) + schemaType.getLocalPart());
    }
 else     if ((baseType.getURI() == null) || (baseType.getURI().equalsIgnoreCase(generatedSchema.getTargetNamespace()))) {
      extension.setBaseType(baseType.getName());
    }
 else {
      extension.setBaseType(getPrefixStringForURI(baseType.getURI()) + baseType.getName());
    }
    buildElementsAndAttributes(extension,sdoType);
    ComplexContent complexContent=new ComplexContent();
    complexContent.setExtension(extension);
    complexType.setComplexContent(complexContent);
    return complexType;
  }
  buildElementsAndAttributes(complexType,sdoType);
  return complexType;
}