Buggy code:
public final class GC extends Resource { public int handle ; Drawable drawable ; GCData data ; static final int FOREGROUND = 1 << 0 ; static final int BACKGROUND = 1 << 1 ; static final int FONT = 1 << 2 ; static final int LINE_STYLE = 1 << 3 ; static final int LINE_WIDTH = 1 << 4 ; static final int LINE_CAP = 1 << 5 ; static final int LINE_JOIN = 1 << 6 ; static final int LINE_MITERLIMIT = 1 << 7 ; static final int ALPHA = 1 << 8 ; static final int CLIPPING = 1 << 9 ; static final int TRANSFORM = 1 << 10 ; static final int DRAW = ( ( ( ( ( ( ( GC . FOREGROUND ) | ( GC . LINE_STYLE ) ) | ( GC . LINE_WIDTH ) ) | ( GC . LINE_CAP ) ) | ( GC . LINE_JOIN ) ) | ( GC . ALPHA ) ) | ( GC . CLIPPING ) ) | ( GC . TRANSFORM ) ; static final int FILL = ( ( ( GC . BACKGROUND ) | ( GC . ALPHA ) ) | ( GC . CLIPPING ) ) | ( GC . TRANSFORM ) ; static final int IMAGE = ( ( GC . ALPHA ) | ( GC . CLIPPING ) ) | ( GC . TRANSFORM ) ; static final double [ ] LINE_DOT_ZERO = new double [ ] { 3 , 3 } ; static final double [ ] LINE_DASH_ZERO = new double [ ] { 18 , 6 } ; static final double [ ] LINE_DASHDOT_ZERO = new double [ ] { 9 , 6 , 3 , 6 } ; static final double [ ] LINE_DASHDOTDOT_ZERO = new double [ ] { 9 , 3 , 3 , 3 , 3 , 3 } ; GC ( ) { } public GC ( Drawable drawable ) { } public GC ( Drawable drawable , int style ) { } static int checkStyle ( int style ) { } void checkGC ( int mask ) { int state = data . state ; if ( ( state & mask ) == mask ) return ; state = ( state ^ mask ) & mask ; data . state |= mask ; if ( ( state & ( ( ( ( ( ( GC . FOREGROUND ) | ( GC . LINE_WIDTH ) ) | ( GC . LINE_STYLE ) ) | ( GC . LINE_JOIN ) ) | ( GC . LINE_CAP ) ) | ( GC . LINE_MITERLIMIT ) ) ) != 0 ) { int pen = data . pen ; if ( pen != 0 ) OS . GCHandle_Free ( pen ) ; pen = data . pen = OS . gcnew_Pen ( ) ; int brush ; Pattern pattern = data . foregroundPattern ; if ( pattern != null ) { brush = pattern . handle ; } else { int foreground = data . foreground ; brush = OS . gcnew_SolidColorBrush ( foreground ) ; if ( brush == 0 ) SWT . error ( ERROR_NO_HANDLES ) ; } OS . Pen_Brush ( pen , brush ) ; if ( pattern == null ) OS . GCHandle_Free ( brush ) ; float width = data . lineWidth ; <START_BUG> OS . Pen_Thickness ( pen , width ) ; <END_BUG> double [ ] dashes = null ; int dashStyle = 0 ; switch ( data . lineStyle ) { case SWT . LINE_SOLID : dashStyle = OS . DashStyles_Solid ( ) ; break ; case SWT . LINE_DOT : if ( width == 0 ) dashes = GC . LINE_DOT_ZERO ; else dashStyle = OS . DashStyles_Dot ( ) ; break ; case SWT . LINE_DASH : if ( width == 0 ) dashes = GC . LINE_DASH_ZERO ; else dashStyle = OS . DashStyles_Dash ( ) ; break ; case SWT . LINE_DASHDOT : if ( width == 0 ) dashes = GC . LINE_DASHDOT_ZERO ; else dashStyle = OS . DashStyles_DashDot ( ) ; break ; case SWT . LINE_DASHDOTDOT : if ( width == 0 ) dashes = GC . LINE_DASHDOTDOT_ZERO ; else dashStyle = OS . DashStyles_DashDotDot ( ) ; break ; case SWT . LINE_CUSTOM : { if ( ( data . lineDashes ) != null ) { dashes = new double [ ( data . lineDashes . length ) * 2 ] ; for ( int i = 0 ; i < ( data . lineDashes . length ) ; i ++ ) { double dash = ( ( double ) ( data . lineDashes [ i ] ) ) // ( Math . max ( 1 , width ) ) ; dashes [ i ] = dash ; dashes [ ( i + ( data . lineDashes . length ) ) ] = dash ; } } else { dashStyle = OS . DashStyles_Solid ( ) ; } } } if ( dashes != null ) { int list = OS . gcnew_DoubleCollection ( dashes . length ) ; for ( int i = 0 ; i < ( dashes . length ) ; i ++ ) { OS . DoubleCollection_Add ( list , dashes [ i ] ) ; } dashStyle = OS . gcnew_DashStyle ( list , data . lineDashesOffset ) ; OS . GCHandle_Free ( list ) ; } OS . Pen_DashStyle ( pen , dashStyle ) ; OS . GCHandle_Free ( dashStyle ) ; int joinStyle = 0 ; switch ( data . lineJoin ) { case SWT . JOIN_MITER : joinStyle = OS . PenLineJoin_Miter ; break ; case SWT . JOIN_BEVEL : joinStyle = OS . PenLineJoin_Bevel ; break ; case SWT . JOIN_ROUND : joinStyle = OS . PenLineJoin_Round ; break ; } OS . Pen_LineJoin ( pen , joinStyle ) ; int capStyle = OS . PenLineCap_Flat ;

Fix:
OS . Pen_Thickness ( pen , ( width == 0 ? 1 : width ) ) ;