Buggy code:
; static final int [ ] SIMPLE_BOTTOM_RIGHT_CORNER = new int [ ] { - 2 , 0 , - 1 , - 1 , 0 , - 2 } ; static final int [ ] SIMPLE_UNSELECTED_INNER_CORNER = new int [ ] { 0 , 0 } ; static final int [ ] TOP_LEFT_CORNER_BORDERLESS = new int [ ] { 0 , 6 , 1 , 5 , 1 , 4 , 4 , 1 , 5 , 1 , 6 , 0 } ; static final int [ ] TOP_RIGHT_CORNER_BORDERLESS = new int [ ] { - 7 , 0 , - 6 , 1 , - 5 , 1 , - 2 , 4 , - 2 , 5 , - 1 , 6 } ; static final int [ ] BOTTOM_LEFT_CORNER_BORDERLESS = new int [ ] { 0 , - 6 , 1 , - 6 , 1 , - 5 , 2 , - 4 , 4 , - 2 , 5 , - 1 , 6 , - 1 , 6 , 0 } ; static final int [ ] BOTTOM_RIGHT_CORNER_BORDERLESS = new int [ ] { - 7 , 0 , - 7 , - 1 , - 6 , - 1 , - 5 , - 2 , - 3 , - 4 , - 2 , - 5 , - 2 , - 6 , - 1 , - 6 } ; static final int [ ] SIMPLE_TOP_LEFT_CORNER_BORDERLESS = new int [ ] { 0 , 2 , 1 , 1 , 2 , 0 } ; static final int [ ] SIMPLE_TOP_RIGHT_CORNER_BORDERLESS = new int [ ] { - 3 , 0 , - 2 , 1 , - 1 , 2 } ; static final int [ ] SIMPLE_BOTTOM_LEFT_CORNER_BORDERLESS = new int [ ] { 0 , - 3 , 1 , - 2 , 2 , - 1 , 3 , 0 } ; static final int [ ] SIMPLE_BOTTOM_RIGHT_CORNER_BORDERLESS = new int [ ] { - 4 , 0 , - 3 , - 1 , - 2 , - 2 , - 1 , - 3 } ; static final int SELECTION_FOREGROUND = SWT . COLOR_LIST_FOREGROUND ; static final int SELECTION_BACKGROUND = SWT . COLOR_LIST_BACKGROUND ; static final int BORDER1_COLOR = SWT . COLOR_WIDGET_NORMAL_SHADOW ; static final int FOREGROUND = SWT . COLOR_WIDGET_FOREGROUND ; static final int BACKGROUND = SWT . COLOR_WIDGET_BACKGROUND ; static final int BUTTON_BORDER = SWT . COLOR_WIDGET_DARK_SHADOW ; static final int BUTTON_FILL = SWT . COLOR_LIST_BACKGROUND ; static final int NONE = 0 ; static final int NORMAL = 1 ; static final int HOT = 2 ; static final int SELECTED = 3 ; static final RGB CLOSE_FILL = new RGB ( 252 , 160 , 160 ) ; static final int CHEVRON_CHILD_ID = 0 ; static final int MINIMIZE_CHILD_ID = 1 ; static final int MAXIMIZE_CHILD_ID = 2 ; static final int EXTRA_CHILD_ID_COUNT = 3 ; public CTabFolder ( Composite parent , int style ) { } void init ( int style ) { } static int checkStyle ( Composite parent , int style ) { } static void fillRegion ( GC gc , Region region ) { } public void addCTabFolder2Listener ( CTabFolder2Listener listener ) { } public void addCTabFolderListener ( CTabFolderListener listener ) { } public void addSelectionListener ( SelectionListener listener ) { } void antialias ( int [ ] shape , RGB lineRGB , RGB innerRGB , RGB outerRGB , GC gc ) { } public Rectangle computeTrim ( int x , int y , int width , int height ) { } void createItem ( CTabItem item , int index ) { if ( ( 0 > index ) || ( index > ( getItemCount ( ) ) ) ) SWT . error ( ERROR_INVALID_RANGE ) ; item . parent = this ; CTabItem [ ] newItems = new CTabItem [ ( items . length ) + 1 ] ; System . arraycopy ( items , 0 , newItems , 0 , index ) ; newItems [ index ] = item ; System . arraycopy ( items , index , newItems , ( index + 1 ) , ( ( items . length ) - index ) ) ; items = newItems ; <START_BUG> if ( ( selectedIndex ) >= index ) <END_BUG> ( selectedIndex ) ++ ; int [ ] newPriority = new int [ ( priority . length ) + 1 ] ; int next = 0 ; int priorityIndex = priority . length ; for ( int i = 0 ; i < ( priority . length ) ; i ++ ) { if ( ( ! ( mru ) ) && ( ( priority [ i ] ) == index ) ) { priorityIndex = next ++ ; } newPriority [ ( next ++ ) ] = ( ( priority [ i ] ) >= index ) ? ( priority [ i ] ) + 1 : priority [ i ] ; } newPriority [ priorityIndex ] = index ; priority = newPriority ; if ( ( items . length ) == 1 ) { if ( ! ( updateTabHeight ( false ) ) ) updateItems ( ) ; redraw ( ) ; } else { updateItems ( ) ; redrawTabs ( ) ; } } void destroyItem ( CTabItem item ) { } void drawBackground ( GC gc , int [ ] shape , boolean selected ) { } void drawBackground ( GC gc , int [ ] shape , int x , int y , int width , int height , Color defaultBackground , Image image , Color [ ] colors , int [ ] percents , boolean vertical ) { } void drawBody ( Event event ) { } void drawChevron ( GC gc ) { } void drawMaximize ( GC gc ) { } void drawMinimize ( GC gc ) { } void drawTabArea ( Event event ) { }

Fix:
if ( ( ( selectedIndex ) >= index ) || ( index == 0 ) )