Buggy code:
alert . setAlertStyle ( alertType ) ; int mask = ( ( ( ( ( ( SWT . YES ) | ( SWT . NO ) ) | ( SWT . OK ) ) | ( SWT . CANCEL ) ) | ( SWT . ABORT ) ) | ( SWT . RETRY ) ) | ( SWT . IGNORE ) ; int bits = ( style ) & mask ; NSString title ; switch ( bits ) { case SWT . OK : title = NSString . stringWith ( SWT . getMessage ( "SWT_OK" ) ) ; alert . addButtonWithTitle ( title ) ; break ; case SWT . CANCEL : title = NSString . stringWith ( SWT . getMessage ( "SWT_Cancel" ) ) ; alert . addButtonWithTitle ( title ) ; break ; case ( SWT . OK ) | ( SWT . CANCEL ) : title = NSString . stringWith ( SWT . getMessage ( "SWT_OK" ) ) ; alert . addButtonWithTitle ( title ) ; title = NSString . stringWith ( SWT . getMessage ( "SWT_Cancel" ) ) ; alert . addButtonWithTitle ( title ) ; break ; case SWT . YES : title = NSString . stringWith ( SWT . getMessage ( "SWT_Yes" ) ) ; alert . addButtonWithTitle ( title ) ; break ; case SWT . NO : title = NSString . stringWith ( SWT . getMessage ( "SWT_No" ) ) ; alert . addButtonWithTitle ( title ) ; break ; case ( SWT . YES ) | ( SWT . NO ) : title = NSString . stringWith ( SWT . getMessage ( "SWT_Yes" ) ) ; alert . addButtonWithTitle ( title ) ; title = NSString . stringWith ( SWT . getMessage ( "SWT_No" ) ) ; alert . addButtonWithTitle ( title ) ; break ; case ( ( SWT . YES ) | ( SWT . NO ) ) | ( SWT . CANCEL ) : title = NSString . stringWith ( SWT . getMessage ( "SWT_Yes" ) ) ; alert . addButtonWithTitle ( title ) ; title = NSString . stringWith ( SWT . getMessage ( "SWT_Cancel" ) ) ; alert . addButtonWithTitle ( title ) ; title = NSString . stringWith ( SWT . getMessage ( "SWT_No" ) ) ; alert . addButtonWithTitle ( title ) ; break ; case ( SWT . RETRY ) | ( SWT . CANCEL ) : title = NSString . stringWith ( SWT . getMessage ( "SWT_Retry" ) ) ; alert . addButtonWithTitle ( title ) ; title = NSString . stringWith ( SWT . getMessage ( "SWT_Cancel" ) ) ; alert . addButtonWithTitle ( title ) ; break ; case ( ( SWT . ABORT ) | ( SWT . RETRY ) ) | ( SWT . IGNORE ) : title = NSString . stringWith ( SWT . getMessage ( "SWT_Abort" ) ) ; alert . addButtonWithTitle ( title ) ; title = NSString . stringWith ( SWT . getMessage ( "SWT_Ignore" ) ) ; alert . addButtonWithTitle ( title ) ; title = NSString . stringWith ( SWT . getMessage ( "SWT_Retry" ) ) ; alert . addButtonWithTitle ( title ) ; break ; } title = NSString . stringWith ( ( ( this . title ) != null ? this . title : "" ) ) ; alert . window ( ) . setTitle ( title ) ; NSString message = NSString . stringWith ( ( ( this . message ) != null ? this . message : "" ) ) ; alert . setMessageText ( message ) ; int response = 0 ; int jniRef = 0 ; SWTPanelDelegate delegate = null ; Display display = ( ( parent ) != null ) ? parent . getDisplay ( ) : Display . getCurrent ( ) ; if ( ( ( style ) & ( SWT . SHEET ) ) != 0 ) { delegate = ( ( SWTPanelDelegate ) ( new SWTPanelDelegate ( ) . alloc ( ) . init ( ) ) ) ; jniRef = OS . NewGlobalRef ( this ) ; if ( jniRef == 0 ) SWT . error ( ERROR_NO_HANDLES ) ; OS . object_setInstanceVariable ( delegate . id , SWT_OBJECT , jniRef ) ; <START_BUG> alert . beginSheetModalForWindow ( window , delegate , sel_panelDidEnd_returnCode_contextInfo_ , 0 ) ; <END_BUG> display . setModalDialog ( this ) ; if ( ( ( style ) & ( SWT . APPLICATION_MODAL ) ) != 0 ) { response = ( ( int ) ( alert . runModal ( ) ) ) ; } else { this . returnCode = 0 ; NSWindow window = alert . window ( ) ; while ( window . isVisible ( ) ) { if ( ! ( display . readAndDispatch ( ) ) ) display . sleep ( ) ; } response = this . returnCode ; } } else { display . setModalDialog ( this ) ; response = ( ( int ) ( alert . runModal ( ) ) ) ; } display . setModalDialog ( null ) ; if ( delegate != null ) delegate . release ( ) ; if ( jniRef != 0 ) OS . DeleteGlobalRef ( jniRef ) ; alert . release ( ) ; switch ( bits ) { case SWT . OK : switch ( response ) { case OS . NSAlertFirstButtonReturn : return SWT . OK ; } break ; case SWT . CANCEL : switch ( response ) { case OS . NSAlertFirstButtonReturn : return SWT . CANCEL ; } break ; case ( SWT . OK ) | ( SWT . CANCEL ) : switch ( response ) { case OS . NSAlertFirstButtonReturn : return SWT . OK ; case OS . NSAlertSecondButtonReturn : return SWT . CANCEL ; } break ; case SWT . YES : switch ( response ) { case OS . NSAlertFirstButtonReturn : return SWT . YES ; }

Fix:
alert . beginSheetModalForWindow ( view . window ( ) , delegate , sel_panelDidEnd_returnCode_contextInfo_ , 0 ) ;