Buggy code:
public static boolean checkSimpleDerivationOk ( XSSimpleType derived , XSTypeDefinition base , short block ) { } public static boolean checkComplexDerivationOk ( XSComplexTypeDecl derived , XSTypeDefinition base , short block ) { } private static boolean checkSimpleDerivation ( XSSimpleType derived , XSSimpleType base , short block ) { } private static boolean checkComplexDerivation ( XSComplexTypeDecl derived , XSTypeDefinition base , short block ) { } public static Object ElementDefaultValidImmediate ( XSTypeDefinition type , String value , ValidationContext context , ValidatedInfo vinfo ) { } static void reportSchemaError ( XMLErrorReporter errorReporter , SimpleLocator loc , String key , Object [ ] args ) { } public static void fullSchemaChecking ( XSGrammarBucket grammarBucket , SubstitutionGroupHandler SGHandler , CMBuilder cmBuilder , XMLErrorReporter errorReporter ) { SchemaGrammar [ ] grammars = grammarBucket . getGrammars ( ) ; for ( int i = ( grammars . length ) - 1 ; i >= 0 ; i -- ) { SGHandler . addSubstitutionGroup ( grammars [ i ] . getSubstitutionGroups ( ) ) ; } XSParticleDecl fakeDerived = new XSParticleDecl ( ) ; XSParticleDecl fakeBase = new XSParticleDecl ( ) ; fakeDerived . fType = XSParticleDecl . PARTICLE_MODELGROUP ; fakeBase . fType = XSParticleDecl . PARTICLE_MODELGROUP ; for ( int g = ( grammars . length ) - 1 ; g >= 0 ; g -- ) { XSGroupDecl [ ] redefinedGroups = grammars [ g ] . getRedefinedGroupDecls ( ) ; SimpleLocator [ ] rgLocators = grammars [ g ] . getRGLocators ( ) ; for ( int i = 0 ; i < ( redefinedGroups . length ) ; ) { XSGroupDecl derivedGrp = redefinedGroups [ ( i ++ ) ] ; XSModelGroupImpl derivedMG = derivedGrp . fModelGroup ; XSGroupDecl baseGrp = redefinedGroups [ ( i ++ ) ] ; XSModelGroupImpl baseMG = baseGrp . fModelGroup ; if ( baseMG == null ) { if ( derivedMG != null ) { XSConstraints . reportSchemaError ( errorReporter , rgLocators [ ( ( i // 2 ) - 1 ) ] , "src-redefine.6.2.2" , new Object [ ] { derivedGrp . fName , "rcase-Recurse.2" } ) ; } } else { fakeDerived . fValue = derivedMG ; fakeBase . fValue = baseMG ; try { XSConstraints . particleValidRestriction ( fakeDerived , SGHandler , fakeBase , SGHandler ) ; } catch ( XMLSchemaException e ) { String key = e . getKey ( ) ; XSConstraints . reportSchemaError ( errorReporter , rgLocators [ ( ( i // 2 ) - 1 ) ] , key , e . getArgs ( ) ) ; XSConstraints . reportSchemaError ( errorReporter , rgLocators [ ( ( i // 2 ) - 1 ) ] , "src-redefine.6.2.2" , new Object [ ] { derivedGrp . fName , key } ) ; } } } } XSComplexTypeDecl [ ] types ; SimpleLocator [ ] ctLocators ; boolean further ; boolean fullChecked ; int keepType ; SymbolHash elemTable = new SymbolHash ( ) ; for ( int i = ( grammars . length ) - 1 , j , k ; i >= 0 ; i -- ) { keepType = 0 ; fullChecked = grammars [ i ] . fFullChecked ; types = grammars [ i ] . getUncheckedComplexTypeDecls ( ) ; ctLocators = grammars [ i ] . getUncheckedCTLocators ( ) ; <START_BUG> for ( j = ( types . length ) - 1 ; j >= 0 ; j -- ) { <END_BUG> if ( ! fullChecked ) { if ( ( types [ j ] . fParticle ) != null ) { elemTable . clear ( ) ; try { XSConstraints . checkElementDeclsConsistent ( types [ j ] , types [ j ] . fParticle , elemTable , SGHandler ) ; } catch ( XMLSchemaException e ) { XSConstraints . reportSchemaError ( errorReporter , ctLocators [ j ] , e . getKey ( ) , e . getArgs ( ) ) ; } } } if ( ( ( ( ( types [ j ] . fBaseType ) != null ) && ( ( types [ j ] . fBaseType ) != ( SchemaGrammar . fAnyType ) ) ) && ( ( types [ j ] . fDerivedBy ) == ( XSConstants . DERIVATION_RESTRICTION ) ) ) && ( ( types [ j ] . fBaseType ) instanceof XSComplexTypeDecl ) ) { XSParticleDecl derivedParticle = types [ j ] . fParticle ; XSParticleDecl baseParticle = ( ( XSComplexTypeDecl ) ( types [ j ] . fBaseType ) ) . fParticle ; if ( derivedParticle == null ) { if ( ( baseParticle != null ) && ( ! ( baseParticle . emptiable ( ) ) ) ) { XSConstraints . reportSchemaError ( errorReporter , ctLocators [ j ] , "derivation-ok-restriction.5.3.2" , new Object [ ] { types [ j ] . fName , types [ j ] . fBaseType . getName ( ) } ) ; } } else if ( baseParticle != null ) { try { XSConstraints . particleValidRestriction ( types [ j ] . fParticle , SGHandler , ( ( XSComplexTypeDecl ) ( types [ j ] . fBaseType ) ) . fParticle , SGHandler ) ; } catch ( XMLSchemaException e ) { XSConstraints . reportSchemaError ( errorReporter , ctLocators [ j ] , e . getKey ( ) , e . getArgs ( ) ) ; XSConstraints . reportSchemaError ( errorReporter , ctLocators [ j ] , "derivation-ok-restriction.5.4.2" , new Object [ ] { types [ j ] . fName } ) ; } } else { XSConstraints . reportSchemaError ( errorReporter , ctLocators [ j ] , "derivation-ok-restriction.5.4.2" , new Object [ ] { types [ j ] . fName } ) ; } } XSCMValidator cm = types [ j ] . getContentModel ( cmBuilder ) ; further = false ; if ( cm != null ) { try { further = cm . checkUniqueParticleAttribution ( SGHandler ) ;

Fix:
for ( j = 0 ; j < ( types . length ) ; j ++ ) {