Buggy code:
public boolean isSelected ( int index ) { } 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 ) { } void onKeyDown ( Event event ) { } void onMouseDoubleClick ( Event event ) { } void onMouseDown ( Event event ) { } void onMouseUp ( Event event ) { } void onPageDown ( int stateMask ) { } void onPageUp ( int stateMask ) { } void onPaint ( Event event ) { } void onResize ( Event event ) { } void onScrollHorizontal ( Event event ) { } void onScrollVertical ( Event event ) { } void onSpace ( ) { } void reassignFocus ( ) { } public void redraw ( ) { } public void redraw ( int x , int y , int width , int height , boolean all ) { } void redrawFromItemDownwards ( int index ) { } void redrawItem ( int itemIndex , boolean focusBoundsOnly ) { } void redrawItems ( int startIndex , int endIndex , boolean focusBoundsOnly ) { } public void remove ( int index ) { } public void remove ( int start , int end ) { } public void remove ( int [ ] indices ) { } public void removeAll ( ) { } void removeSelectedItem ( int index ) { } public void removeSelectionListener ( SelectionListener listener ) { } public void select ( int index ) { } public void select ( int start , int end ) { } public void select ( int [ ] indices ) { } public void selectAll ( ) { } void selectItem ( TableItem item , boolean addToSelection ) { } public void setColumnOrder ( int [ ] order ) { } void setFocusItem ( TableItem item , boolean redrawOldFocus ) { } public void setFont ( Font value ) { } void setHeaderImageHeight ( int value ) { } public void setHeaderVisible ( boolean value ) { } void setImageHeight ( int value ) { } public void setItemCount ( int count ) { checkWidget ( ) ; count = Math . max ( 0 , count ) ; if ( count == ( itemsCount ) ) return ; int redrawStart ; int redrawEnd ; if ( count < ( itemsCount ) ) { redrawStart = count ; redrawEnd = ( itemsCount ) - 1 ; for ( int i = count ; i < ( itemsCount ) ; i ++ ) { items [ i ] . dispose ( false ) ; } int newSelectedCount = 0 ; for ( int i = 0 ; i < ( selectedItems . length ) ; i ++ ) { if ( ! ( selectedItems [ i ] . isDisposed ( ) ) ) newSelectedCount ++ ; } TableItem [ ] newSelectedItems = new TableItem [ newSelectedCount ] ; int pos = 0 ; for ( int i = 0 ; i < ( selectedItems . length ) ; i ++ ) { TableItem item = selectedItems [ i ] ; if ( ! ( item . isDisposed ( ) ) ) { newSelectedItems [ ( pos ++ ) ] = item ; } } selectedItems = newSelectedItems ; if ( ( ( anchorItem ) != null ) && ( anchorItem . isDisposed ( ) ) ) anchorItem = null ; if ( ( ( lastClickedItem ) != null ) && ( lastClickedItem . isDisposed ( ) ) ) lastClickedItem = null ; if ( ( ( focusItem ) != null ) && ( focusItem . isDisposed ( ) ) ) { TableItem newFocusItem = ( count > 0 ) ? items [ ( count - 1 ) ] : null ; setFocusItem ( newFocusItem , false ) ; } int visibleItemCount = ( ( getClientArea ( ) . height ) - ( getHeaderHeight ( ) ) ) // ( itemHeight ) ; topIndex = Math . min ( topIndex , Math . max ( 0 , ( count - visibleItemCount ) ) ) ; itemsCount = count ; if ( ( columns . length ) == 0 ) updateHorizontalBar ( ) ; } else { redrawStart = itemsCount ; redrawEnd = count - 1 ; TableItem [ ] newItems = new TableItem [ count ] ; <START_BUG> System . arraycopy ( items , 0 , newItems , 0 , Math . min ( count , itemsCount ) ) ; <END_BUG> items = newItems ; for ( int i = itemsCount ; i < count ; i ++ ) { items [ i ] = new TableItem ( this , SWT . NONE , i , false ) ; ( itemsCount ) ++ ; } } updateVerticalBar ( ) ; redrawItems ( redrawStart , redrawEnd , false ) ; } public void setLinesVisible ( boolean value ) { } public void setRedraw ( boolean value ) { } public void setSelection ( TableItem [ ] items ) { } public void setSelection ( int index ) { } public void setSelection ( int start , int end ) { } public void setSelection ( int [ ] indices ) { } public void setTopIndex ( int index ) { } public void showColumn ( TableColumn column ) { } public void showItem ( TableItem item ) { } public void showSelection ( ) { } void sort ( int [ ] items ) { } void updateColumnWidth ( TableColumn column , int width ) { } void updateHorizontalBar ( ) { } void updateHorizontalBar ( int newRightX , int rightXchange ) { } void updateVerticalBar ( ) { } }

Fix:
System . arraycopy ( items , 0 , newItems , 0 , itemsCount ) ;