Buggy code:
public class TreeItem extends Item { public int handle ; Tree parent ; String [ ] strings ; Image [ ] images ; boolean cached ; int background = - 1 ; int foreground = - 1 ; int font = - 1 ; int [ ] cellBackground ; int [ ] cellForeground ; int [ ] cellFont ; public TreeItem ( Tree parent , int style ) { } public TreeItem ( Tree parent , int style , int index ) { } public TreeItem ( TreeItem parentItem , int style ) { } public TreeItem ( TreeItem parentItem , int style , int index ) { } static TreeItem checkNull ( TreeItem item ) { } protected void checkSubclass ( ) { } void clear ( ) { } void clear ( int index , boolean all ) { } void clearAll ( boolean all ) { } public Color getBackground ( ) { } public Color getBackground ( int index ) { } public Rectangle getBounds ( ) { } public Rectangle getBounds ( int index ) { } RECT getBounds ( int index , boolean getText , boolean getImage , boolean full ) { } public boolean getChecked ( ) { } public boolean getExpanded ( ) { } public Font getFont ( ) { } public Font getFont ( int index ) { } public Color getForeground ( ) { } public Color getForeground ( int index ) { } public boolean getGrayed ( ) { } public TreeItem getItem ( int index ) { } public int getItemCount ( ) { } public TreeItem [ ] getItems ( ) { } public Image getImage ( ) { } public Image getImage ( int index ) { } public Rectangle getImageBounds ( int index ) { } public Tree getParent ( ) { } public TreeItem getParentItem ( ) { } public String getText ( ) { } public String getText ( int index ) { } public int indexOf ( TreeItem item ) { } void redraw ( ) { } void redraw ( int column , boolean drawText , boolean drawImage ) { } void releaseChild ( ) { } void releaseHandle ( ) { } void releaseWidget ( ) { } public void removeAll ( ) { } public void setBackground ( Color color ) { } public void setBackground ( int index , Color color ) { } public void setChecked ( boolean checked ) { } public void setExpanded ( boolean expanded ) { } public void setFont ( Font font ) { } public void setFont ( int index , Font font ) { } public void setForeground ( Color color ) { } public void setForeground ( int index , Color color ) { } public void setGrayed ( boolean grayed ) { } public void setImage ( Image [ ] images ) { } public void setImage ( int index , Image image ) { checkWidget ( ) ; if ( ( image != null ) && ( image . isDisposed ( ) ) ) { error ( ERROR_INVALID_ARGUMENT ) ; } if ( index == 0 ) { if ( ( image != null ) && ( ( image . type ) == ( SWT . ICON ) ) ) { if ( image . equals ( this . image ) ) return ; } super . setImage ( image ) ; } int count = Math . max ( 1 , parent . getColumnCount ( ) ) ; if ( ( 0 > index ) || ( index > ( count - 1 ) ) ) return ; if ( ( ( images ) == null ) && ( index != 0 ) ) images = new Image [ count ] ; if ( ( images ) != null ) { if ( ( image != null ) && ( ( image . type ) == ( SWT . ICON ) ) ) { if ( image . equals ( images [ index ] ) ) return ; } images [ index ] = image ; } if ( ( ( parent . style ) & ( SWT . VIRTUAL ) ) != 0 ) cached = true ; <START_BUG> parent . imageIndex ( image ) ; <END_BUG> if ( index == 0 ) { int hwnd = parent . handle ; TVITEM tvItem = new TVITEM ( ) ; tvItem . mask = ( ( OS . TVIF_HANDLE ) | ( OS . TVIF_IMAGE ) ) | ( OS . TVIF_SELECTEDIMAGE ) ; tvItem . hItem = handle ; tvItem . iImage = tvItem . iSelectedImage = OS . I_IMAGECALLBACK ; tvItem . mask |= OS . TVIF_TEXT ; tvItem . pszText = OS . LPSTR_TEXTCALLBACK ; OS . SendMessage ( hwnd , TVM_SETITEM , 0 , tvItem ) ; } else { redraw ( index , false , true ) ; } } public void setImage ( Image image ) { } public void setText ( String [ ] strings ) { } void setItemCount ( int count ) { } public void setText ( int index , String string ) { } public void setText ( String string ) { } }

Fix:
parent . imageIndex ( image , index ) ;