Buggy code:
public class TabFolder extends Composite { TabItem [ ] items = new TabItem [ 0 ] ; int selectedIndex = - 1 ; int xClient ; int yClient ; int imageHeight = - 1 ; int topTabIndex = 0 ; boolean scrollButtonDown = false ; boolean inDispose = false ; String toolTipText ; static final int SCROLL_BUTTON_SIZE = 20 ; static final int CLIENT_MARGIN_WIDTH = 2 ; static final int SELECTED_TAB_TOP_EXPANSION = 2 ; static final int SELECTED_TAB_HORIZONTAL_EXPANSION = 2 ; public TabFolder ( Composite parent , int style ) { } public void addSelectionListener ( SelectionListener listener ) { } static int checkStyle ( int style ) { } protected void checkSubclass ( ) { } public Point computeSize ( int wHint , int hHint , boolean changed ) { } public Rectangle computeTrim ( int x , int y , int width , int height ) { } void createChild ( TabItem item , int index ) { } void destroyChild ( TabItem item ) { } void doDispose ( ) { } void drawArrow ( GC gc , int xPos , int yPos , int size , boolean left ) { } void drawBorder ( Event event ) { } void drawPlainButton ( GC gc , int xPos , int yPos , int size ) { } void drawScrollButtons ( Event event ) { } void ensureRightFreeSpaceUsed ( ) { } void ensureVisible ( int tabIndex ) { } void focus ( Event e ) { } public Rectangle getClientArea ( ) { } int getImageHeight ( ) { } public TabItem getItem ( int index ) { } public int getItemCount ( ) { } public TabItem [ ] getItems ( ) { } char getMnemonic ( String string ) { } Rectangle getScrollButtonArea ( ) { } public TabItem [ ] getSelection ( ) { } public int getSelectionIndex ( ) { } public String getToolTipText ( ) { } void handleEvents ( Event event ) { } public int indexOf ( TabItem item ) { } boolean isLeftButtonHit ( Event event ) { } boolean isRightButtonHit ( Event event ) { } boolean isTabScrolling ( ) { } void itemChanged ( TabItem item ) { } void keyDown ( Event event ) { int count = items . length ; <START_BUG> if ( count < 2 ) <END_BUG> return ; if ( ( event . keyCode ) == ( SWT . ARROW_RIGHT ) ) { if ( ( selectedIndex ) < ( ( items . length ) - 1 ) ) { setSelection ( ( ( selectedIndex ) + 1 ) , true ) ; } } if ( ( event . keyCode ) == ( SWT . ARROW_LEFT ) ) { if ( ( selectedIndex ) > 0 ) { setSelection ( ( ( selectedIndex ) - 1 ) , true ) ; } } if ( ( event . keyCode ) == ( SWT . HOME ) ) { if ( ( selectedIndex ) > 0 ) { setSelection ( 0 , true ) ; } } if ( ( event . keyCode ) == ( SWT . END ) ) { if ( ( selectedIndex ) < ( count - 1 ) ) { setSelection ( ( count - 1 ) , true ) ; } } } void layoutItems ( ) { } Point minimumSize ( int wHint , int hHint , boolean flushCache ) { } boolean mnemonicHit ( char key ) { } void mouseDown ( Event event ) { } void mouseHover ( Event event ) { } void mouseUp ( Event event ) { } void paint ( Event event ) { } void redraw ( int x , int y , int width , int height ) { } void redrawHitButton ( Event event ) { } void redrawScrollButtons ( ) { } void redrawSelectionChange ( int oldSelection , int newSelection ) { } void redrawTabs ( ) { } void removeControl ( Control control ) { } public void removeSelectionListener ( SelectionListener listener ) { } void resize ( ) { } void scrollLeft ( ) { } void scrollRight ( ) { } boolean setBounds ( int x , int y , int width , int height , boolean move , boolean resize ) { } public void setFont ( Font font ) { } public void setSelection ( int index ) { } public void setSelection ( TabItem [ ] selectedItems ) { } void setSelection ( int index , boolean notify ) { } public void setToolTipText ( String string ) { } void traversal ( Event event ) { } boolean traverseItem ( boolean next ) { } boolean traversePage ( boolean next ) { } }

Fix:
if ( count <= 1 )