Buggy code:
private GraphvizFormatter dotOut ; public void setGraphvizFormatter ( GraphvizFormatter dotOut ) { } @ Override public void reset ( Reader input ) throws IOException { } @ Override public void reset ( ) throws IOException { } private void resetState ( ) { } @ Override public void end ( ) { } private int computeSecondBestThreshold ( int pos , int length ) throws IOException { } private int computePenalty ( int pos , int length ) throws IOException { } static final class Position { int pos ; int count ; int [ ] costs = new int [ 8 ] ; int [ ] lastRightID = new int [ 8 ] ; int [ ] backPos = new int [ 8 ] ; int [ ] backIndex = new int [ 8 ] ; int [ ] backID = new int [ 8 ] ; KuromojiTokenizer . Type [ ] backType = new KuromojiTokenizer . Type [ 8 ] ; int forwardCount ; int [ ] forwardPos = new int [ 8 ] ; int [ ] forwardID = new int [ 8 ] ; int [ ] forwardIndex = new int [ 8 ] ; KuromojiTokenizer . Type [ ] forwardType = new KuromojiTokenizer . Type [ 8 ] ; public void grow ( ) { } public void growForward ( ) { } public void add ( int cost , int lastRightID , int backPos , int backIndex , int backID , KuromojiTokenizer . Type backType ) { } public void addForward ( int forwardPos , int forwardIndex , int forwardID , KuromojiTokenizer . Type forwardType ) { } public void reset ( ) { } } private void add ( Dictionary dict , KuromojiTokenizer . Position fromPosData , int endPos , int wordID , KuromojiTokenizer . Type type , boolean addPenalty ) throws IOException { } @ Override public boolean incrementToken ( ) throws IOException { } static final class WrappedPositionArray { private KuromojiTokenizer . Position [ ] positions = new KuromojiTokenizer . Position [ 8 ] ; public WrappedPositionArray ( ) { } private int nextWrite ; private int nextPos ; private int count ; public void reset ( ) { } public KuromojiTokenizer . Position get ( int pos ) { } public int getNextPos ( ) { } private boolean inBounds ( int pos ) { } private int getIndex ( int pos ) { } public void freeBefore ( int pos ) { } } private void parse ( ) throws IOException { if ( KuromojiTokenizer . VERBOSE ) { System . out . println ( "\nPARSE" ) ; } while ( true ) { if ( ( buffer . get ( pos ) ) == ( - 1 ) ) { break ; } final KuromojiTokenizer . Position posData = positions . get ( pos ) ; final boolean isFrontier = ( positions . getNextPos ( ) ) == ( ( pos ) + 1 ) ; if ( ( posData . count ) == 0 ) { ( pos ) ++ ; if ( KuromojiTokenizer . VERBOSE ) { System . out . println ( "<seq2seq4repair_space>no<seq2seq4repair_space>arcs<seq2seq4repair_space>in;<seq2seq4repair_space>skip" ) ; } continue ; } if ( ( ( ( pos ) > ( lastBackTracePos ) ) && ( ( posData . count ) == 1 ) ) && isFrontier ) { backtrace ( posData , 0 ) ; posData . costs [ 0 ] = 0 ; if ( ( pending . size ( ) ) != 0 ) { return ; } else { } } if ( ( ( pos ) - ( lastBackTracePos ) ) >= ( KuromojiTokenizer . MAX_BACKTRACE_GAP ) ) { int leastIDX = - 1 ; int leastCost = Integer . MAX_VALUE ; KuromojiTokenizer . Position leastPosData = null ; for ( int pos2 = pos ; pos2 < ( positions . getNextPos ( ) ) ; pos2 ++ ) { final KuromojiTokenizer . Position posData2 = positions . get ( pos2 ) ; for ( int idx = 0 ; idx < ( posData2 . count ) ; idx ++ ) { <START_BUG> final int cost = posData . costs [ idx ] ; <END_BUG> if ( cost < leastCost ) { leastCost = cost ; leastIDX = idx ; leastPosData = posData2 ; } } } assert leastIDX != ( - 1 ) ; for ( int pos2 = pos ; pos2 < ( positions . getNextPos ( ) ) ; pos2 ++ ) { final KuromojiTokenizer . Position posData2 = positions . get ( pos2 ) ; if ( posData2 != leastPosData ) { posData2 . reset ( ) ; } else { if ( leastIDX != 0 ) { posData2 . costs [ 0 ] = posData2 . costs [ leastIDX ] ; posData2 . lastRightID [ 0 ] = posData2 . lastRightID [ leastIDX ] ; posData2 . backPos [ 0 ] = posData2 . backPos [ leastIDX ] ; posData2 . backIndex [ 0 ] = posData2 . backIndex [ leastIDX ] ; posData2 . backID [ 0 ] = posData2 . backID [ leastIDX ] ; posData2 . backType [ 0 ] = posData2 . backType [ leastIDX ] ; } posData2 . count = 1 ; } } backtrace ( leastPosData , 0 ) ; Arrays . fill ( leastPosData . costs , 0 , leastPosData . count , 0 ) ; if ( ( pending . size ( ) ) != 0 ) { return ; } else { if ( ( pos ) != ( leastPosData . pos ) ) { assert ( pos ) < ( leastPosData . pos ) ; continue ; } } } if ( KuromojiTokenizer . VERBOSE ) { System . out . println ( ( ( ( "\n<seq2seq4repair_space>extend<seq2seq4repair_space>@<seq2seq4repair_space>pos=" + ( pos ) ) + "<seq2seq4repair_space>char=" ) + ( ( char ) ( buffer . get ( pos ) ) ) ) ) ; }

Fix:
final int cost = posData2 . costs [ idx ] ;