Buggy code:
public class Text extends Scrollable { int textLimit = Text . LIMIT ; int tabs = 8 ; char echoCharacter ; boolean doubleClick ; boolean receivingFocus ; String hiddenText ; String message ; NSRange selectionRange ; id targetSearch ; id targetCancel ; int actionSearch ; int actionCancel ; public static final int LIMIT ; public static final String DELIMITER ; static final char PASSWORD = '•' ; public Text ( Composite parent , int style ) { } public void addModifyListener ( ModifyListener listener ) { } public void addSelectionListener ( SelectionListener listener ) { } public void addVerifyListener ( VerifyListener listener ) { } public void append ( String string ) { } boolean becomeFirstResponder ( int id , int sel ) { } static int checkStyle ( int style ) { } public void clearSelection ( ) { } public Point computeSize ( int wHint , int hHint , boolean changed ) { } public Rectangle computeTrim ( int x , int y , int width , int height ) { } public void copy ( ) { } void createHandle ( ) { } void createWidget ( ) { } public void cut ( ) { } Color defaultBackground ( ) { } NSFont defaultNSFont ( ) { } Color defaultForeground ( ) { } void deregister ( ) { } boolean dragDetect ( int x , int y , boolean filter , boolean [ ] consume ) { } public int getCaretLineNumber ( ) { } boolean acceptsFirstResponder ( int id , int sel ) { } public Point getCaretLocation ( ) { } public int getCaretPosition ( ) { } public int getCharCount ( ) { } public boolean getDoubleClickEnabled ( ) { } public char getEchoChar ( ) { } public boolean getEditable ( ) { } char [ ] getEditText ( ) { } char [ ] getEditText ( int start , int end ) { } public int getLineCount ( ) { } public String getLineDelimiter ( ) { } public int getLineHeight ( ) { } public int getOrientation ( ) { } public String getMessage ( ) { } int getPosition ( int x , int y ) { } public Point getSelection ( ) { } public int getSelectionCount ( ) { } public String getSelectionText ( ) { } public int getTabs ( ) { } public String getText ( ) { } public String getText ( int start , int end ) { } public int getTextLimit ( ) { } public int getTopIndex ( ) { } public int getTopPixel ( ) { } public void insert ( String string ) { } void insertEditText ( String string ) { } boolean isEventView ( int id ) { } public void paste ( ) { } void register ( ) { } void releaseWidget ( ) { } public void removeModifyListener ( ModifyListener listener ) { } public void removeSelectionListener ( SelectionListener listener ) { } public void removeVerifyListener ( VerifyListener listener ) { } public void selectAll ( ) { } boolean sendKeyEvent ( NSEvent nsEvent , int type ) { } void sendSearchSelection ( ) { } void sendCancelSelection ( ) { } void updateBackground ( ) { } public void setDoubleClickEnabled ( boolean doubleClick ) { } public void setEchoChar ( char echo ) { } public void setEditable ( boolean editable ) { } void setEditText ( String string ) { } void setFont ( NSFont font ) { } void setForeground ( float [ ] color ) { } public void setOrientation ( int orientation ) { } public void setMessage ( String message ) { } public void setSelection ( int start ) { } public void setSelection ( int start , int end ) { } public void setSelection ( Point selection ) { } public void setTabs ( int tabs ) { } public void setText ( String string ) { } public void setTextLimit ( int limit ) { } public void setTopIndex ( int index ) { checkWidget ( ) ; if ( ( ( style ) & ( SWT . SINGLE ) ) != 0 ) return ; <START_BUG> int row = Math . max ( 0 , Math . min ( index , getLineCount ( ) ) ) ; <END_BUG> NSPoint pt = new NSPoint ( ) ; pt . x = scrollView . contentView ( ) . bounds ( ) . x ; pt . y = ( getLineHeight ( ) ) * row ; view . scrollPoint ( pt ) ; } boolean shouldChangeTextInRange_replacementString ( int id , int sel , int affectedCharRange , int replacementString ) { } public void showSelection ( ) { } void textViewDidChangeSelection ( int id , int sel , int aNotification ) { } void textDidChange ( int id , int sel , int aNotification ) { } NSRange textView_willChangeSelectionFromCharacterRange_toCharacterRange ( int id , int sel , int aTextView , int oldSelectedCharRange , int newSelectedCharRange ) { } int traversalCode ( int key , NSEvent theEvent ) { } void updateCursorRects ( boolean enabled ) { } String verifyText ( String string , int start , int end , NSEvent keyEvent ) { } }

Fix:
int row = Math . max ( 0 , Math . min ( index , ( ( getLineCount ( ) ) - 1 ) ) ) ;