Buggy code:
if ( mixedContent && hadContent ) { left = fSchemaGrammar . addContentSpecNode ( CONTENTSPECNODE_ZERO_OR_MORE , left , ( - 1 ) , false ) ; } } if ( ( ! derivedByRestriction ) && ( baseContentSpecHandle > ( - 1 ) ) ) { left = fSchemaGrammar . addContentSpecNode ( CONTENTSPECNODE_SEQ , baseContentSpecHandle , left , false ) ; } if ( ( ( ( content . length ( ) ) == 0 ) && ( ( base . length ( ) ) == 0 ) ) && ( left == ( - 2 ) ) ) { contentSpecType = XMLElementDecl . TYPE_ANY ; } if ( TraverseSchema . DEBUGGING ) System . out . println ( ( ( ( ( ( ( ( ( ( "!!!!!>>>>>" + typeName ) + ",<seq2seq4repair_space>" ) + baseTypeInfo ) + ",<seq2seq4repair_space>" ) + baseContentSpecHandle ) + ",<seq2seq4repair_space>" ) + left ) + ",<seq2seq4repair_space>" ) + scopeDefined ) ) ; TraverseSchema . ComplexTypeInfo typeInfo = new TraverseSchema . ComplexTypeInfo ( ) ; typeInfo . baseComplexTypeInfo = baseTypeInfo ; typeInfo . baseDataTypeValidator = baseTypeValidator ; int derivedByInt = - 1 ; if ( ( derivedBy . length ( ) ) > 0 ) { derivedByInt = parseComplexDerivedBy ( derivedBy ) ; } typeInfo . derivedBy = derivedByInt ; typeInfo . scopeDefined = scopeDefined ; typeInfo . contentSpecHandle = left ; typeInfo . contentType = contentSpecType ; typeInfo . datatypeValidator = simpleTypeValidator ; typeInfo . blockSet = parseBlockSet ( complexTypeDecl . getAttribute ( ATT_BLOCK ) ) ; typeInfo . finalSet = parseFinalSet ( complexTypeDecl . getAttribute ( ATT_FINAL ) ) ; int typeNameIndex = fStringPool . addSymbol ( typeName ) ; int templateElementNameIndex = fStringPool . addSymbol ( ( "$" + typeName ) ) ; typeInfo . templateElementIndex = fSchemaGrammar . addElementDecl ( new QName ( ( - 1 ) , templateElementNameIndex , typeNameIndex , fTargetNSURI ) , ( ( fTargetNSURI ) == ( - 1 ) ? - 1 : fCurrentScope ) , scopeDefined , contentSpecType , left , ( - 1 ) , simpleTypeValidator ) ; typeInfo . attlistHead = fSchemaGrammar . getFirstAttributeDeclIndex ( typeInfo . templateElementIndex ) ; for ( child = XUtil . getFirstChildElement ( complexTypeDecl ) ; child != null ; child = XUtil . getNextSiblingElement ( child ) ) { String childName = child . getNodeName ( ) ; if ( childName . equals ( ELT_ATTRIBUTE ) ) { if ( ( baseIsComplexSimple || baseIsSimpleSimple ) && derivedByRestriction ) { reportGenericSchemaError ( ( ( "In<seq2seq4repair_space>complexType<seq2seq4repair_space>" + typeName ) + ",<seq2seq4repair_space>base<seq2seq4repair_space>type<seq2seq4repair_space>has<seq2seq4repair_space>simpleType<seq2seq4repair_space>content<seq2seq4repair_space>and<seq2seq4repair_space>derivation<seq2seq4repair_space>method<seq2seq4repair_space>is<seq2seq4repair_space>'restriction',<seq2seq4repair_space>can't<seq2seq4repair_space>have<seq2seq4repair_space>any<seq2seq4repair_space>attribute<seq2seq4repair_space>children<seq2seq4repair_space>at<seq2seq4repair_space>all" ) ) ; break ; } traverseAttributeDecl ( child , typeInfo ) ; } else if ( childName . equals ( ELT_ATTRIBUTEGROUP ) ) { if ( ( baseIsComplexSimple || baseIsSimpleSimple ) && derivedByRestriction ) { reportGenericSchemaError ( ( ( "In<seq2seq4repair_space>complexType<seq2seq4repair_space>" + typeName ) + ",<seq2seq4repair_space>base<seq2seq4repair_space>type<seq2seq4repair_space>has<seq2seq4repair_space>simpleType<seq2seq4repair_space>content<seq2seq4repair_space>and<seq2seq4repair_space>derivation<seq2seq4repair_space>method<seq2seq4repair_space>is<seq2seq4repair_space>'restriction',<seq2seq4repair_space>can't<seq2seq4repair_space>have<seq2seq4repair_space>any<seq2seq4repair_space>attribute<seq2seq4repair_space>children<seq2seq4repair_space>at<seq2seq4repair_space>all" ) ) ; break ; } traverseAttributeGroupDecl ( child , typeInfo ) ; } } typeInfo . attlistHead = fSchemaGrammar . getFirstAttributeDeclIndex ( typeInfo . templateElementIndex ) ; if ( ( baseTypeInfo != null ) && ( ( baseTypeInfo . attlistHead ) > ( - 1 ) ) ) { int attDefIndex = baseTypeInfo . attlistHead ; while ( attDefIndex > ( - 1 ) ) { fSchemaGrammar . getAttributeDecl ( attDefIndex , fTempAttributeDecl ) ; attDefIndex = fSchemaGrammar . getNextAttributeDeclIndex ( attDefIndex ) ; if ( ( fSchemaGrammar . getAttributeDeclIndex ( typeInfo . templateElementIndex , fTempAttributeDecl . name ) ) > ( - 1 ) ) { if ( derivedByRestriction ) { continue ; } } fSchemaGrammar . addAttDef ( typeInfo . templateElementIndex , fTempAttributeDecl . name , fTempAttributeDecl . type , ( - 1 ) , fTempAttributeDecl . defaultType , fTempAttributeDecl . defaultValue , fTempAttributeDecl . datatypeValidator ) ; } } if ( ! ( typeName . startsWith ( "#" ) ) ) { typeName = ( ( fTargetNSURIString ) + "," ) + typeName ; } fComplexTypeRegistry . put ( typeName , typeInfo ) ; fCurrentScope = previousScope ; if ( isNamedType ) { fCurrentTypeNameStack . pop ( ) ; checkRecursingComplexType ( ) ; <START_BUG> fCurrentTypeNameStack . clear ( ) ; <END_BUG> } typeNameIndex = fStringPool . addSymbol ( typeName ) ; return typeNameIndex ; } private void checkRecursingComplexType ( ) throws Exception { } private void checkParticleDerivationOK ( Element derivedTypeNode , Element baseTypeNode ) { } private int expandContentModel ( int index , Element particle ) throws Exception { } private int traverseAttributeDecl ( Element attrDecl , TraverseSchema . ComplexTypeInfo typeInfo ) throws Exception { } private int addAttributeDeclFromAnotherSchema ( String name , String uriStr , TraverseSchema . ComplexTypeInfo typeInfo ) throws Exception { } private int traverseAttributeGroupDecl ( Element attrGrpDecl , TraverseSchema . ComplexTypeInfo typeInfo ) throws Exception { } private int traverseAttributeGroupDeclFromAnotherSchema ( String attGrpName , String uriStr , TraverseSchema . ComplexTypeInfo typeInfo ) throws Exception { } private QName traverseElementDecl ( Element elementDecl ) throws Exception { } int getLocalPartIndex ( String fullName ) { } String getLocalPart ( String fullName ) { } private void checkEquivClassOK ( Element elementDecl , Element equivClassElementDecl ) { } private Element getTopLevelComponentByName ( String componentCategory , String name ) throws Exception { } private boolean isTopLevel ( Element component ) { } DatatypeValidator getTypeValidatorFromNS ( String newSchemaURI , String localpart ) { } TraverseSchema . ComplexTypeInfo getTypeInfoFromNS ( String newSchemaURI , String localpart ) { } private int traverseGroupDecl ( Element groupDecl ) throws Exception { } private int traverseGroupDeclFromAnotherSchema ( String groupName , String uriStr ) throws Exception { } int traverseSequence ( Element sequenceDecl ) throws Exception { } int traverseChoice ( Element choiceDecl ) throws Exception { } int traverseAll ( Element allDecl ) throws Exception { } private int buildAllModel ( int [ ] children , int count ) throws Exception { } private int buildAllModel ( int [ ] src , int offset , XMLContentSpec choice ) throws Exception { } private int createSeq ( int [ ] src ) throws Exception { }

Fix:
fElementRecurseComplex . clear ( ) ;