Buggy code:
public class XSConstraints { static final int OCCURRENCE_UNKNOWN = ( SchemaSymbols . OCCURRENCE_UNBOUNDED ) - 1 ; static final XSSimpleType STRING_TYPE = ( ( XSSimpleType ) ( SG_SchemaNS . getGlobalTypeDecl ( ATTVAL_STRING ) ) ) ; public static boolean checkTypeDerivationOk ( XSTypeDecl derived , XSTypeDecl base , short block ) { } public static boolean checkSimpleDerivationOk ( XSSimpleType derived , XSTypeDecl base , short block ) { } public static boolean checkComplexDerivationOk ( XSComplexTypeDecl derived , XSTypeDecl base , short block ) { } private static boolean checkSimpleDerivation ( XSSimpleType derived , XSSimpleType base , short block ) { if ( derived == base ) return true ; if ( ( ( block & ( XSConstants . DERIVATION_RESTRICTION ) ) != 0 ) || ( ( ( derived . getBaseType ( ) . getFinal ( ) ) & ( XSConstants . DERIVATION_RESTRICTION ) ) != 0 ) ) { return false ; } XSSimpleType directBase = ( ( XSSimpleType ) ( derived . getBaseType ( ) ) ) ; if ( directBase == base ) return true ; if ( ( directBase != ( SchemaGrammar . fAnySimpleType ) ) && ( XSConstraints . checkSimpleDerivation ( directBase , base , block ) ) ) { return true ; } if ( ( ( ( derived . getVariety ( ) ) == ( XSSimpleType . VARIETY_LIST ) ) || ( ( derived . getVariety ( ) ) == ( XSSimpleType . VARIETY_UNION ) ) ) && ( base == ( SchemaGrammar . fAnySimpleType ) ) ) { return true ; } if ( ( base . getVariety ( ) ) == ( XSSimpleType . VARIETY_UNION ) ) { XSObjectList subUnionMemberDV = base . getMemberTypes ( ) ; <START_BUG> int subUnionSize = subUnionMemberDV . getListLength ( ) ; <END_BUG> for ( int i = 0 ; i < subUnionSize ; i ++ ) { base = ( ( XSSimpleType ) ( subUnionMemberDV . getItem ( i ) ) ) ; if ( XSConstraints . checkSimpleDerivation ( derived , base , block ) ) return true ; } } return false ; } private static boolean checkComplexDerivation ( XSComplexTypeDecl derived , XSTypeDecl base , short block ) { } public static Object ElementDefaultValidImmediate ( XSTypeDecl type , Object 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 ) { } 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 void particleValidRestriction ( XSParticleDecl dParticle , SubstitutionGroupHandler dSGHandler , XSParticleDecl bParticle , SubstitutionGroupHandler bSGHandler ) throws XMLSchemaException { } private static void 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 { } private static void checkNSRecurseCheckCardinality ( Vector children , int min1 , int max1 , SubstitutionGroupHandler dSGHandler , XSParticleDecl wildcard , int min2 , int max2 , boolean checkWCOccurrence ) throws XMLSchemaException { } private static void checkRecurse ( Vector dChildren , int min1 , int max1 , SubstitutionGroupHandler dSGHandler , Vector bChildren , int min2 , int max2 , SubstitutionGroupHandler bSGHandler ) throws XMLSchemaException { } private static void checkRecurseUnordered ( Vector dChildren , int min1 , int max1 , SubstitutionGroupHandler dSGHandler , Vector bChildren , int min2 , int max2 , SubstitutionGroupHandler bSGHandler ) throws XMLSchemaException { } private static void checkRecurseLax ( Vector dChildren , int min1 , int max1 , SubstitutionGroupHandler dSGHandler , Vector bChildren , int min2 , int max2 , SubstitutionGroupHandler bSGHandler ) throws XMLSchemaException { } private static void checkMapAndSum ( Vector dChildren , int min1 , int max1 , SubstitutionGroupHandler dSGHandler , Vector bChildren , int min2 , int max2 , SubstitutionGroupHandler bSGHandler ) throws XMLSchemaException { } public static boolean overlapUPA ( XSElementDecl element1 , XSElementDecl element2 , SubstitutionGroupHandler sgHandler ) { } public static boolean overlapUPA ( XSElementDecl element , XSWildcardDecl wildcard , SubstitutionGroupHandler sgHandler ) { } public static boolean overlapUPA ( XSWildcardDecl wildcard1 , XSWildcardDecl wildcard2 ) { } public static boolean overlapUPA ( Object decl1 , Object decl2 , SubstitutionGroupHandler sgHandler ) { } }

Fix:
int subUnionSize = subUnionMemberDV . getLength ( ) ;