Buggy code:
} NSMutableDictionary dictionary = nsthread . threadDictionary ( ) ; NSString key = NSString . stringWith ( "SWT_NSAutoreleasePool" ) ; NSNumber id = new NSNumber ( dictionary . objectForKey ( key ) ) ; addPool ( new NSAutoreleasePool ( id . integerValue ( ) ) ) ; application = NSApplication . sharedApplication ( ) ; isEmbedded = application . isRunning ( ) ; int [ ] psn = new int [ 2 ] ; if ( ( OS . GetCurrentProcess ( psn ) ) == ( OS . noErr ) ) { int pid = OS . getpid ( ) ; int ptr = Display . getAppName ( ) . UTF8String ( ) ; if ( ptr != 0 ) OS . CPSSetProcessName ( psn , ptr ) ; if ( ! ( isBundled ( ) ) ) { OS . TransformProcessType ( psn , kProcessTransformToForegroundApplication ) ; OS . SetFrontProcess ( psn ) ; } ptr = OS . getenv ( Display . ascii ( ( "APP_ICON_" + pid ) ) ) ; if ( ptr != 0 ) { NSString path = NSString . stringWithUTF8String ( ptr ) ; NSImage image = ( ( NSImage ) ( new NSImage ( ) . alloc ( ) ) ) ; image = image . initByReferencingFile ( path ) ; dockImage = image ; application . setApplicationIconImage ( image ) ; } } String className = "SWTApplication" ; int cls ; if ( ( cls = OS . objc_lookUpClass ( className ) ) == 0 ) { Class clazz = getClass ( ) ; Display . applicationCallback2 = new Callback ( clazz , "applicationProc" , 2 ) ; int proc2 = Display . applicationCallback2 . getAddress ( ) ; if ( proc2 == 0 ) error ( ERROR_NO_MORE_CALLBACKS ) ; Display . applicationCallback3 = new Callback ( clazz , "applicationProc" , 3 ) ; int proc3 = Display . applicationCallback3 . getAddress ( ) ; if ( proc3 == 0 ) error ( ERROR_NO_MORE_CALLBACKS ) ; Display . applicationCallback4 = new Callback ( clazz , "applicationProc" , 4 ) ; int proc4 = Display . applicationCallback4 . getAddress ( ) ; if ( proc4 == 0 ) error ( ERROR_NO_MORE_CALLBACKS ) ; Display . applicationCallback6 = new Callback ( clazz , "applicationProc" , 6 ) ; int proc6 = Display . applicationCallback6 . getAddress ( ) ; if ( proc6 == 0 ) error ( ERROR_NO_MORE_CALLBACKS ) ; cls = OS . objc_allocateClassPair ( OS . object_getClass ( application . id ) , className , 0 ) ; OS . class_addMethod ( cls , sel_sendEvent_ , proc3 , "@:@" ) ; OS . class_addMethod ( cls , sel_nextEventMatchingMask_untilDate_inMode_dequeue_ , proc6 , "@:i@@B" ) ; OS . class_addMethod ( cls , sel_isRunning , proc2 , "@:" ) ; OS . class_addMethod ( cls , sel_finishLaunching , proc2 , "@:" ) ; OS . objc_registerClassPair ( cls ) ; } applicationClass = OS . object_setClass ( application . id , cls ) ; className = "SWTApplicationDelegate" ; if ( ( OS . objc_lookUpClass ( className ) ) == 0 ) { int appProc3 = Display . applicationCallback3 . getAddress ( ) ; if ( appProc3 == 0 ) error ( ERROR_NO_MORE_CALLBACKS ) ; cls = OS . objc_allocateClassPair ( class_NSObject , className , 0 ) ; int appProc4 = Display . applicationCallback4 . getAddress ( ) ; if ( appProc4 == 0 ) error ( ERROR_NO_MORE_CALLBACKS ) ; cls = OS . objc_allocateClassPair ( class_NSObject , className , 0 ) ; OS . class_addMethod ( cls , sel_applicationWillFinishLaunching_ , appProc3 , "@:@" ) ; OS . class_addMethod ( cls , sel_terminate_ , appProc3 , "@:@" ) ; OS . class_addMethod ( cls , sel_quitRequested_ , appProc3 , "@:@" ) ; OS . class_addMethod ( cls , sel_orderFrontStandardAboutPanel_ , appProc3 , "@:@" ) ; OS . class_addMethod ( cls , sel_hideOtherApplications_ , appProc3 , "@:@" ) ; OS . class_addMethod ( cls , sel_hide_ , appProc3 , "@:@" ) ; OS . class_addMethod ( cls , sel_unhideAllApplications_ , appProc3 , "@:@" ) ; OS . class_addMethod ( cls , sel_applicationDidBecomeActive_ , appProc3 , "@:@" ) ; OS . class_addMethod ( cls , sel_applicationDidResignActive_ , appProc3 , "@:@" ) ; <START_BUG> OS . class_addMethod ( cls , sel_application_openFile_ , appProc4 , "@:@B" ) ; <END_BUG> OS . class_addMethod ( cls , sel_application_openFiles_ , appProc4 , "@:@@" ) ; OS . class_addMethod ( cls , sel_applicationShouldHandleReopen_hasVisibleWindows_ , appProc4 , "@:@B" ) ; OS . objc_registerClassPair ( cls ) ; } if ( ! ( isEmbedded ) ) { if ( ( Display . applicationDelegate ) == null ) { Display . applicationDelegate = ( ( SWTApplicationDelegate ) ( new SWTApplicationDelegate ( ) . alloc ( ) . init ( ) ) ) ; application . setDelegate ( Display . applicationDelegate ) ; } } int [ ] bufferMode = new int [ 1 ] ; int [ ] bufferOptions = new int [ 1 ] ; OS . GetSystemUIMode ( bufferMode , bufferOptions ) ; systemUIMode = bufferMode [ 0 ] ; systemUIOptions = bufferOptions [ 0 ] ; } void createMainMenu ( ) { } int cursorSetProc ( int id , int sel ) { } static void deregister ( Display display ) { } protected void destroy ( ) { } void destroyDisplay ( ) { } public void disposeExec ( Runnable runnable ) { } void error ( int code ) { } boolean filterEvent ( Event event ) { } boolean filters ( int eventType ) { } public Widget findWidget ( int handle ) { } public Widget findWidget ( int handle , int id ) { } public Widget findWidget ( Widget widget , int id ) { } public static Display findDisplay ( Thread thread ) { } public Shell getActiveShell ( ) { } public Rectangle getBounds ( ) { } Rectangle getBounds ( NSArray screens ) { } public static Display getCurrent ( ) { }

Fix:
OS . class_addMethod ( cls , sel_application_openFile_ , appProc4 , "@:@@" ) ;