Buggy code:
public Image ( Device device , ImageData data ) { } public Image ( Device device , ImageData source , ImageData mask ) { } public Image ( Device device , InputStream stream ) { } public Image ( Device device , String filename ) { } void createAlpha ( ) { } void destroy ( ) { } public boolean equals ( Object object ) { } public Color getBackground ( ) { } public Rectangle getBounds ( ) { } public ImageData getImageData ( ) { } public static Image cocoa_new ( Device device , int type , NSImage nsImage ) { } public int hashCode ( ) { } void init ( int width , int height ) { } void init ( ImageData image ) { } void initNative ( String filename ) { NSAutoreleasePool pool = null ; if ( ! ( NSThread . isMainThread ( ) ) ) pool = ( ( NSAutoreleasePool ) ( new NSAutoreleasePool ( ) . alloc ( ) . init ( ) ) ) ; try { handle = new NSImage ( ) ; handle . alloc ( ) ; handle = handle . initWithContentsOfFile ( NSString . stringWith ( filename ) ) ; if ( ( handle ) == null ) SWT . error ( ERROR_INVALID_IMAGE ) ; NSImageRep rep = handle . bestRepresentationForDevice ( null ) ; if ( rep . isKindOfClass ( class_NSBitmapImageRep ) ) { rep . retain ( ) ; imageRep = new NSBitmapImageRep ( rep . id ) ; } else { NSArray reps = handle . representations ( ) ; if ( reps != null ) { int repCount = reps . count ( ) ; for ( int i = 0 ; i < repCount ; i ++ ) { NSImageRep currentRep = new NSImageRep ( reps . objectAtIndex ( i ) . id ) ; if ( currentRep . isKindOfClass ( class_NSBitmapImageRep ) ) { currentRep . retain ( ) ; imageRep = new NSBitmapImageRep ( currentRep . id ) ; break ; } } } if ( ( imageRep ) == null ) { imageRep = new NSBitmapImageRep ( NSBitmapImageRep . imageRepWithData ( handle . TIFFRepresentation ( ) ) . id ) ; imageRep . retain ( ) ; handle . addRepresentation ( imageRep ) ; } } NSString colorSpace = imageRep . colorSpaceName ( ) ; if ( ! ( colorSpace . isEqualToString ( NSCalibratedRGBColorSpace ) ) ) SWT . error ( ERROR_INVALID_IMAGE ) ; height = ( ( int ) ( imageRep . pixelsHigh ( ) ) ) ; width = ( ( int ) ( imageRep . pixelsWide ( ) ) ) ; NSSize size = new NSSize ( ) ; size . height = height ; size . width = width ; handle . setSize ( size ) ; byte [ ] alphaData = null ; if ( imageRep . hasAlpha ( ) ) { int bitmapBytesPerRow = width ; int bitmapByteCount = bitmapBytesPerRow * ( height ) ; int alphaBitmapData = OS . malloc ( bitmapByteCount ) ; int alphaBitmapCtx = OS . CGBitmapContextCreate ( alphaBitmapData , width , height , 8 , bitmapBytesPerRow , 0 , kCGImageAlphaOnly ) ; NSGraphicsContext . static_saveGraphicsState ( ) ; NSGraphicsContext . setCurrentContext ( NSGraphicsContext . graphicsContextWithGraphicsPort ( alphaBitmapCtx , false ) ) ; NSRect imageRect = new NSRect ( ) ; imageRect . x = imageRect . y = 0 ; imageRect . width = handle . size ( ) . width ; imageRect . height = handle . size ( ) . height ; NSRect zeroRect = new NSRect ( ) ; zeroRect . x = zeroRect . y = zeroRect . height = zeroRect . width = 0 ; handle . drawInRect ( imageRect , zeroRect , NSCompositeCopy , 1.0F ) ; NSGraphicsContext . static_restoreGraphicsState ( ) ; alphaData = new byte [ ( ( int ) ( bitmapByteCount ) ) ] ; OS . memmove ( alphaData , alphaBitmapData , bitmapByteCount ) ; OS . free ( alphaBitmapData ) ; OS . CGContextRelease ( alphaBitmapCtx ) ; boolean hasTransparentPixel = true ; int transparentColor = - 1 ; int alphaOffset = 0 ; transparentScan : { for ( int y = 0 ; y < ( height ) ; y ++ ) { for ( int x = 0 ; x < ( width ) ; x ++ ) { if ( ( ( alphaData [ alphaOffset ] ) != 0 ) && ( ( alphaData [ alphaOffset ] ) != ( - 1 ) ) ) { hasTransparentPixel = false ; break transparentScan ; } if ( ( alphaData [ alphaOffset ] ) == 0 ) { NSColor color = imageRep . colorAtX ( x , y ) ; int red = ( ( int ) ( ( color . redComponent ( ) ) * 255 ) ) ; int green = ( ( int ) ( ( color . greenComponent ( ) ) * 255 ) ) ; int blue = ( ( int ) ( ( color . blueComponent ( ) ) * 255 ) ) ; transparentColor = ( ( red << 16 ) + ( green << 8 ) ) + blue ; } alphaOffset += 1 ; } } } if ( hasTransparentPixel ) this . transparentPixel = transparentColor ; } this . alphaData = alphaData ; <START_BUG> if ( filename . endsWith ( ".ico" ) ) { <END_BUG> this . type = SWT . ICON ; } else { this . type = SWT . BITMAP ; } } finally { if ( pool != null ) pool . release ( ) ; } } public int internal_new_GC ( GCData data ) { } public void internal_dispose_GC ( int context , GCData data ) { } public boolean isDisposed ( ) { } public void setBackground ( Color color ) { } public String toString ( ) { } }

Fix:
if ( filename . toLowerCase ( ) . endsWith ( ".ico" ) ) {