Buggy code:
public final class TypeAlgorithms { public static final Comparator < Automaton . State > DATA_COMPARATOR = new Comparator < Automaton . State > ( ) { public int compare ( Automaton . State s1 , Automaton . State s2 ) { } } ; public static boolean isContractive ( Automaton automata ) { } private static boolean findContractives ( Automaton automata , BitSet contractives ) { } private static boolean isContractive ( int index , BitSet contractives , Automaton automata ) { } public static void simplify ( Automaton automata ) { } private static boolean simplifyContractives ( Automaton automata ) { } private static boolean simplify ( int index , Automaton automata ) { } private static boolean simplifyNegation ( int index , Automaton . State state , Automaton automata ) { } private static boolean simplifyCompound ( int index , Automaton . State state , Automaton automata ) { } private static boolean simplifyUnion ( int index , Automaton . State state , Automaton automata ) { } private static boolean simplifyUnion_1 ( int index , Automaton . State state , Automaton automata ) { } private static boolean simplifyUnion_2 ( int index , Automaton . State state , Automaton automata ) { } private static boolean isSubtype ( int fromIndex , int toIndex , Automaton automata ) { } private static final class IntersectionPoint { public final int fromIndex ; public final boolean fromSign ; public final int toIndex ; public final boolean toSign ; public IntersectionPoint ( int fromIndex , boolean fromSign , int toIndex , boolean toSign ) { } public boolean equals ( Object o ) { } public int hashCode ( ) { } } public static Type intersect ( Type t1 , Type t2 ) { } private static Automaton intersect ( boolean fromSign , Automaton from , boolean toSign , Automaton to ) { } private static int intersect ( int fromIndex , boolean fromSign , Automaton from , int toIndex , boolean toSign , Automaton to , HashMap < TypeAlgorithms . IntersectionPoint , Integer > allocations , ArrayList < Automaton . State > states ) { } private static int intersectDifferentKind ( int fromIndex , boolean fromSign , Automaton from , int toIndex , boolean toSign , Automaton to , HashMap < TypeAlgorithms . IntersectionPoint , Integer > allocations , ArrayList < Automaton . State > states ) { } private static int intersectSameKindPosPos ( int fromIndex , Automaton from , int toIndex , Automaton to , HashMap < TypeAlgorithms . IntersectionPoint , Integer > allocations , ArrayList < Automaton . State > states ) { } private static State intersectPosPosOpenOpen ( int fromIndex , Automaton from , int toIndex , Automaton to , HashMap < TypeAlgorithms . IntersectionPoint , Integer > allocations , ArrayList < Automaton . State > states ) { Automaton . State fromState = from . states [ fromIndex ] ; <START_BUG> Automaton . State toState = from . states [ toIndex ] ; <END_BUG> Type . Record . State fromData = ( ( Type . Record . State ) ( fromState . data ) ) ; Type . Record . State toData = ( ( Type . Record . State ) ( toState . data ) ) ; Type . Record . State myData = new Type . Record . State ( true ) ; int fi = 0 ; int ti = 0 ; int [ ] fromChildren = fromState . children ; int [ ] toChildren = toState . children ; ArrayList < Integer > myChildren = new ArrayList < Integer > ( ) ; while ( ( fi < ( fromData . size ( ) ) ) && ( ti < ( toData . size ( ) ) ) ) { int fromChild = fromChildren [ fi ] ; int toChild = toChildren [ ti ] ; String fn = fromData . get ( fi ) ; String tn = toData . get ( ti ) ; int c = fn . compareTo ( tn ) ; if ( c == 0 ) { myData . add ( fn ) ; myChildren . add ( TypeAlgorithms . intersect ( fromChild , true , from , toChild , true , to , allocations , states ) ) ; fi ++ ; ti ++ ; } else if ( c < 0 ) { myData . add ( fn ) ; myChildren . add ( states . size ( ) ) ; Automata . extractOnto ( fromChild , from , states ) ; fi ++ ; } else { myData . add ( tn ) ; myChildren . add ( states . size ( ) ) ; Automata . extractOnto ( toChild , to , states ) ; ti ++ ; } } while ( fi < ( fromData . size ( ) ) ) { String fn = fromData . get ( fi ) ; myData . add ( fn ) ; int fromChild = fromChildren [ fi ] ; myChildren . add ( states . size ( ) ) ; Automata . extractOnto ( fromChild , from , states ) ; fi = fi + 1 ; } while ( ti < ( toData . size ( ) ) ) { String tn = toData . get ( ti ) ; myData . add ( tn ) ; int toChild = toChildren [ ti ] ; myChildren . add ( states . size ( ) ) ; Automata . extractOnto ( toChild , to , states ) ; ti = ti + 1 ; } int [ ] myChildrenArray = new int [ myChildren . size ( ) ] ; for ( int i = 0 ; i != ( myChildrenArray . length ) ; ++ i ) { myChildrenArray [ i ] = myChildren . get ( i ) ; } return new Automaton . State ( fromState . kind , myData , true , myChildrenArray ) ; }

Fix:
Automaton . State toState = to . states [ toIndex ] ;