Buggy code:
) ; } } 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 ; i >= 0 ; i -- ) { keepType = 0 ; fullChecked = grammars [ i ] . fFullChecked ; types = grammars [ i ] . getUncheckedComplexTypeDecls ( ) ; ctLocators = grammars [ i ] . getUncheckedCTLocators ( ) ; for ( j = 0 ; j < ( types . length ) ; j ++ ) { 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 } ) ; } } <START_BUG> XSCMValidator cm = types [ j ] . getContentModel ( cmBuilder ) ; <END_BUG> further = false ; if ( cm != null ) { try { further = cm . checkUniqueParticleAttribution ( SGHandler ) ; } catch ( XMLSchemaException e ) { XSConstraints . reportSchemaError ( errorReporter , ctLocators [ j ] , e . getKey ( ) , e . getArgs ( ) ) ; } } if ( ( ! fullChecked ) && further ) types [ ( keepType ++ ) ] = types [ j ] ; } if ( ! fullChecked ) { grammars [ i ] . setUncheckedTypeNum ( keepType ) ; grammars [ i ] . fFullChecked = true ; } } } public static void checkElementDeclsConsistent ( XSComplexTypeDecl type , XSParticleDecl particle , SymbolHash elemDeclHash , SubstitutionGroupHandler sgHandler ) throws XMLSchemaException { } public static void findElemInTable ( XSComplexTypeDecl type , XSElementDecl elem , SymbolHash elemDeclHash ) throws XMLSchemaException { } private static boolean particleValidRestriction ( XSParticleDecl dParticle , SubstitutionGroupHandler dSGHandler , XSParticleDecl bParticle , SubstitutionGroupHandler bSGHandler ) throws XMLSchemaException { } private static boolean particleValidRestriction ( XSParticleDecl dParticle , SubstitutionGroupHandler dSGHandler , XSParticleDecl bParticle , SubstitutionGroupHandler bSGHandler , boolean checkWCOccurrence ) throws XMLSchemaException { } private static void addElementToParticleVector ( Vector v , XSElementDecl d ) { } private static XSParticleDecl getNonUnaryGroup ( XSParticleDecl p ) { } private static Vector removePointlessChildren ( XSParticleDecl p ) { } private static void gatherChildren ( int parentType , XSParticleDecl p , Vector children ) { } private static void checkNameAndTypeOK ( XSElementDecl dElement , int dMin , int dMax , XSElementDecl bElement , int bMin , int bMax ) throws XMLSchemaException { } private static void checkIDConstraintRestriction ( XSElementDecl derivedElemDecl , XSElementDecl baseElemDecl ) throws XMLSchemaException { } private static boolean checkOccurrenceRange ( int min1 , int max1 , int min2 , int max2 ) { } private static void checkNSCompat ( XSElementDecl elem , int min1 , int max1 , XSWildcardDecl wildcard , int min2 , int max2 , boolean checkWCOccurrence ) throws XMLSchemaException { } private static void checkNSSubset ( XSWildcardDecl dWildcard , int min1 , int max1 , XSWildcardDecl bWildcard , int min2 , int max2 ) throws XMLSchemaException { }

Fix:
XSCMValidator cm = types [ j ] . getContentModel ( cmBuilder , true ) ;