Buggy code:
public class Tree extends Composite { Canvas header ; TreeColumn [ ] columns = new TreeColumn [ 0 ] ; TreeColumn [ ] orderedColumns ; TreeItem [ ] items = new TreeItem [ 0 ] ; TreeItem [ ] availableItems = new TreeItem [ 0 ] ; TreeItem [ ] selectedItems = new TreeItem [ 0 ] ; TreeItem focusItem ; TreeItem anchorItem ; TreeItem insertMarkItem ; TreeItem lastClickedItem ; Event lastSelectionEvent ; int availableItemsCount = 0 ; boolean insertMarkPrecedes = false ; boolean linesVisible ; boolean ignoreKey ; int topIndex = 0 ; int horizontalOffset = 0 ; int fontHeight = 0 ; int imageHeight = 0 ; int itemHeight = 0 ; int col0ImageWidth = 0 ; int headerImageHeight = 0 ; TreeColumn resizeColumn ; int resizeColumnX = - 1 ; int drawCount = 0 ; boolean inExpand = false ; TreeColumn sortColumn ; int sortDirection = SWT . NONE ; Rectangle arrowBounds ; Rectangle expanderBounds ; Rectangle checkboxBounds ; static final int MARGIN_IMAGE = 3 ; static final int MARGIN_CELL = 1 ; static final int SIZE_HORIZONTALSCROLL = 5 ; static final int TOLLERANCE_COLUMNRESIZE = 2 ; static final int WIDTH_HEADER_SHADOW = 2 ; static final int WIDTH_CELL_HIGHLIGHT = 1 ; static final String ELLIPSIS = "..." ; static final String ID_EXPANDED = "EXPANDED" ; static final String ID_COLLAPSED = "COLLAPSED" ; static final String ID_UNCHECKED = "UNCHECKED" ; static final String ID_GRAYUNCHECKED = "GRAYUNCHECKED" ; static final String ID_CHECKMARK = "CHECKMARK" ; static final String ID_CONNECTOR_COLOR = "CONNECTOR_COLOR" ; static final String ID_ARROWUP = "ARROWUP" ; static final String ID_ARROWDOWN = "ARROWDOWN" ; boolean hasFocus ; public boolean isFocusControl ( ) { } public Tree ( Composite parent , int style ) { } public void addSelectionListener ( SelectionListener listener ) { } public void addTreeListener ( TreeListener listener ) { } boolean checkData ( TreeItem item , boolean redraw ) { } static int checkStyle ( int style ) { } void clear ( int index , boolean recursive ) { } void clearAll ( boolean recursive ) { } int computeColumnIntersect ( int x , int startColumn ) { } public Point computeSize ( int wHint , int hHint , boolean changed ) { } void createItem ( TreeColumn column , int index ) { } void createItem ( TreeItem item , int index ) { } public void deselectAll ( ) { } void deselectItem ( TreeItem item ) { } void destroyItem ( TreeColumn column ) { } void destroyItem ( TreeItem item ) { } TreeItem [ ] getAllItems ( ) { } Image getArrowDownImage ( ) { } Image getArrowUpImage ( ) { } int getCellPadding ( ) { } Image getCheckmarkImage ( ) { } public Control [ ] getChildren ( ) { } Image getCollapsedImage ( ) { } public TreeColumn getColumn ( int index ) { } public int getColumnCount ( ) { } int [ ] getColumnOrder ( ) { } public TreeColumn [ ] getColumns ( ) { } Color getConnectorColor ( ) { } Image getExpandedImage ( ) { } Image getGrayUncheckedImage ( ) { } public int getGridLineWidth ( ) { } public int getHeaderHeight ( ) { } int getHeaderPadding ( ) { } public boolean getHeaderVisible ( ) { } public TreeItem getItem ( Point point ) { checkWidget ( ) ; if ( point == null ) error ( ERROR_NULL_ARGUMENT ) ; <START_BUG> int index = ( ( ( point . y ) - ( getHeaderHeight ( ) ) ) // ( itemHeight ) ) - ( topIndex ) ; <END_BUG> if ( ! ( ( 0 <= index ) && ( index < ( availableItemsCount ) ) ) ) return null ; TreeItem result = availableItems [ index ] ; if ( ! ( result . getHitBounds ( ) . contains ( point ) ) ) return null ; return result ; } public TreeItem getItem ( int index ) { } public int getItemCount ( ) { } public int getItemHeight ( ) { } public TreeItem [ ] getItems ( ) { } int getItemY ( TreeItem item ) { } public boolean getLinesVisible ( ) { } TreeColumn [ ] getOrderedColumns ( ) { } public TreeItem getParentItem ( ) { } public TreeItem [ ] getSelection ( ) { } public int getSelectionCount ( ) { } int getSelectionIndex ( TreeItem item ) { } public TreeColumn getSortColumn ( ) { } public int getSortDirection ( ) { } public TreeItem getTopItem ( ) { } Image getUncheckedImage ( ) { } void handleEvents ( Event event ) { } void headerOnMouseDoubleClick ( Event event ) { } void headerOnMouseDown ( Event event ) { } void headerOnMouseExit ( ) { } void headerOnMouseMove ( Event event ) { } void headerOnMouseUp ( Event event ) { } void headerOnPaint ( Event event ) { } void headerPaintHShadows ( GC gc , int x , int y , int width , int height ) { } void headerPaintVShadows ( GC gc , int x , int y , int width , int height ) { } public int indexOf ( TreeColumn column ) { } public int indexOf ( TreeItem item ) { } static void initImages ( final Display display ) { } void makeAvailable ( TreeItem item ) { } void makeDescendentsAvailable ( TreeItem item , TreeItem [ ] descendents ) { } void makeDescendentsUnavailable ( TreeItem item , TreeItem [ ] descendents ) { } void onArrowDown ( int stateMask ) { } void onArrowLeft ( int stateMask ) { } void onArrowRight ( int stateMask ) { } void onArrowUp ( int stateMask ) { } void onCR ( ) { } void onDispose ( ) { } void onEnd ( int stateMask ) { } void onFocusIn ( ) { } void onFocusOut ( ) { } void onHome ( int stateMask ) { }

Fix:
int index = ( ( ( point . y ) - ( getHeaderHeight ( ) ) ) // ( itemHeight ) ) + ( topIndex ) ;