Buggy code:
int [ ] tabs ; int [ ] segments ; char [ ] segmentsChars ; TextLayout . StyleItem [ ] styles ; TextLayout . StyleItem [ ] [ ] runs ; int [ ] lineOffset ; int [ ] lineY ; int [ ] lineWidth ; int defaultAscent ; int defaultDescent ; static final RGB LINK_FOREGROUND = new RGB ( 0 , 51 , 153 ) ; static class StyleItem { TextStyle style ; int start ; int length ; int width ; int height ; int baseline ; boolean lineBreak ; boolean softBreak ; boolean tab ; public String toString ( ) { } } public TextLayout ( Device device ) { } void checkLayout ( ) { } int stringWidth ( TextLayout . StyleItem run , char [ ] ch ) { } void computeRuns ( ) { if ( ( runs ) != null ) return ; TextLayout . StyleItem [ ] allRuns = itemize ( ) ; for ( int i = 0 ; i < ( ( allRuns . length ) - 1 ) ; i ++ ) { TextLayout . StyleItem run = allRuns [ i ] ; place ( run ) ; } int lineWidth = indent ; int lineStart = 0 ; int lineCount = 1 ; for ( int i = 0 ; i < ( ( allRuns . length ) - 1 ) ; i ++ ) { TextLayout . StyleItem run = allRuns [ i ] ; if ( ( run . length ) == 1 ) { char ch = text . charAt ( run . start ) ; switch ( ch ) { case '\t' : { run . tab = true ; run . baseline = 0 ; if ( ( tabs ) == null ) break ; int tabsLength = tabs . length ; int j ; for ( j = 0 ; j < tabsLength ; j ++ ) { if ( ( tabs [ j ] ) > lineWidth ) { run . width = ( tabs [ j ] ) - lineWidth ; break ; } } if ( j == tabsLength ) { int tabX = tabs [ ( tabsLength - 1 ) ] ; int lastTabWidth = ( tabsLength > 1 ) ? ( tabs [ ( tabsLength - 1 ) ] ) - ( tabs [ ( tabsLength - 2 ) ] ) : tabs [ 0 ] ; if ( lastTabWidth > 0 ) { while ( tabX <= lineWidth ) tabX += lastTabWidth ; run . width = tabX - lineWidth ; } } break ; } case '\n' : run . lineBreak = true ; run . baseline = run . width = 0 ; break ; case '\r' : run . lineBreak = true ; run . baseline = run . width = 0 ; TextLayout . StyleItem next = allRuns [ ( i + 1 ) ] ; if ( ( ( next . length ) != 0 ) && ( ( text . charAt ( next . start ) ) == '\n' ) ) { run . length += 1 ; i ++ ; } break ; } } <START_BUG> if ( ( ( ( wrapWidth ) != ( - 1 ) ) && ( ( lineWidth + ( run . width ) ) > ( wrapWidth ) ) ) && ( ! ( run . tab ) ) ) { <END_BUG> int start = 0 ; char [ ] chars = new char [ run . length ] ; text . getChars ( run . start , ( ( run . start ) + ( run . length ) ) , chars , 0 ) ; if ( ! ( ( ( run . style ) != null ) && ( ( run . style . metrics ) != null ) ) ) { int width = 0 ; int maxWidth = ( wrapWidth ) - lineWidth ; char [ ] buffer = new char [ 1 ] ; buffer [ 0 ] = chars [ start ] ; int charWidth = stringWidth ( run , buffer ) ; while ( ( width + charWidth ) < maxWidth ) { width += charWidth ; start ++ ; buffer [ 0 ] = chars [ start ] ; charWidth = stringWidth ( run , buffer ) ; } } int firstStart = start ; int firstIndice = i ; while ( i >= lineStart ) { chars = new char [ run . length ] ; text . getChars ( run . start , ( ( run . start ) + ( run . length ) ) , chars , 0 ) ; while ( start >= 0 ) { if ( ( Compatibility . isSpaceChar ( chars [ start ] ) ) || ( Compatibility . isWhitespace ( chars [ start ] ) ) ) break ; start -- ; } if ( ( start >= 0 ) || ( i == lineStart ) ) break ; run = allRuns [ ( -- i ) ] ; start = ( run . length ) - 1 ; } if ( ( start == 0 ) && ( i != lineStart ) ) { run = allRuns [ ( -- i ) ] ; } else if ( ( start <= 0 ) && ( i == lineStart ) ) { i = firstIndice ; run = allRuns [ i ] ; start = Math . max ( 1 , firstStart ) ; } chars = new char [ run . length ] ; text . getChars ( run . start , ( ( run . start ) + ( run . length ) ) , chars , 0 ) ; while ( start < ( run . length ) ) { if ( ! ( Compatibility . isWhitespace ( chars [ start ] ) ) ) break ; start ++ ;

Fix:
if ( ( ( ( ( wrapWidth ) != ( - 1 ) ) && ( ( lineWidth + ( run . width ) ) > ( wrapWidth ) ) ) && ( ! ( run . tab ) ) ) && ( ( run . length ) > 0 ) ) {