Buggy code:
class XSDComplexTypeTraverser extends XSDAbstractParticleTraverser { private static final int GLOBAL_NUM = 11 ; private String fName = null ; private String fTargetNamespace = null ; private short fDerivedBy = XSConstants . DERIVATION_RESTRICTION ; private short fFinal = XSConstants . DERIVATION_NONE ; private short fBlock = XSConstants . DERIVATION_NONE ; private short fContentType = XSComplexTypeDecl . CONTENTTYPE_EMPTY ; private XSTypeDefinition fBaseType = null ; private XSAttributeGroupDecl fAttrGrp = null ; private XSSimpleType fXSSimpleType = null ; private XSParticleDecl fParticle = null ; private boolean fIsAbstract = false ; private XSComplexTypeDecl fComplexTypeDecl = null ; private XSAnnotationImpl [ ] fAnnotations = null ; private XSParticleDecl fEmptyParticle = null ; private Object [ ] fGlobalStore = null ; private int fGlobalStorePos = 0 ; XSDComplexTypeTraverser ( XSDHandler handler , XSAttributeChecker gAttrCheck ) { } private static final boolean DEBUG = false ; private SchemaDVFactory schemaFactory = SchemaDVFactory . getInstance ( ) ; private static final class ComplexTypeRecoverableError extends Exception { private static final long serialVersionUID = 6802729912091130335L ; Object [ ] errorSubstText = null ; Element errorElem = null ; ComplexTypeRecoverableError ( ) { } ComplexTypeRecoverableError ( String msgKey , Object [ ] args , Element e ) { } } XSComplexTypeDecl traverseLocal ( Element complexTypeNode , XSDocumentInfo schemaDoc , SchemaGrammar grammar ) { } XSComplexTypeDecl traverseGlobal ( Element complexTypeNode , XSDocumentInfo schemaDoc , SchemaGrammar grammar ) { Object [ ] attrValues = fAttrChecker . checkAttributes ( complexTypeNode , true , schemaDoc ) ; String complexTypeName = ( ( String ) ( attrValues [ XSAttributeChecker . ATTIDX_NAME ] ) ) ; contentBackup ( ) ; XSComplexTypeDecl type = traverseComplexTypeDecl ( complexTypeNode , complexTypeName , attrValues , schemaDoc , grammar ) ; contentRestore ( ) ; if ( complexTypeName == null ) { reportSchemaError ( "s4s-att-must-appear" , new Object [ ] { SchemaSymbols . ELT_COMPLEXTYPE , SchemaSymbols . ATT_NAME } , complexTypeNode ) ; } else { <START_BUG> grammar . addGlobalTypeDecl ( type ) ; <END_BUG> } grammar . addComplexTypeDecl ( type , fSchemaHandler . element2Locator ( complexTypeNode ) ) ; fAttrChecker . returnAttrArray ( attrValues , schemaDoc ) ; return type ; } private XSComplexTypeDecl traverseComplexTypeDecl ( Element complexTypeDecl , String complexTypeName , Object [ ] attrValues , XSDocumentInfo schemaDoc , SchemaGrammar grammar ) { } private void traverseSimpleContent ( Element simpleContentElement , XSDocumentInfo schemaDoc , SchemaGrammar grammar ) throws XSDComplexTypeTraverser . ComplexTypeRecoverableError { } private void traverseComplexContent ( Element complexContentElement , boolean mixedOnType , XSDocumentInfo schemaDoc , SchemaGrammar grammar ) throws XSDComplexTypeTraverser . ComplexTypeRecoverableError { } private void mergeAttributes ( XSAttributeGroupDecl fromAttrGrp , XSAttributeGroupDecl toAttrGrp , String typeName , boolean extension , Element elem ) throws XSDComplexTypeTraverser . ComplexTypeRecoverableError { } private void processComplexContent ( Element complexContentChild , boolean isMixed , boolean isDerivation , XSDocumentInfo schemaDoc , SchemaGrammar grammar ) throws XSDComplexTypeTraverser . ComplexTypeRecoverableError { } private boolean isAttrOrAttrGroup ( Element e ) { } private void traverseSimpleContentDecl ( Element simpleContentDecl ) { } private void traverseComplexContentDecl ( Element complexContentDecl , boolean mixedOnComplexTypeDecl ) { } private String genAnonTypeName ( Element complexTypeDecl ) { } private void handleComplexTypeError ( String messageId , Object [ ] args , Element e ) { } private XSParticleDecl getErrorContent ( ) { } private XSWildcardDecl getErrorWildcard ( ) { } private void contentBackup ( ) { } private void contentRestore ( ) { } private void addAnnotation ( XSAnnotationImpl annotation ) { } }

Fix:
grammar . addGlobalComplexTypeDecl ( type ) ;