Buggy code:
public Image getSystemImage ( int id ) { } public Tray getSystemTray ( ) { } public Thread getThread ( ) { } int getToolTipTime ( ) { } Widget getWidget ( int id ) { } static Widget GetWidget ( int id ) { } Widget getWidget ( NSView view ) { } boolean hasDefaultButton ( ) { } protected void init ( ) { } void initApplicationDelegate ( ) { } void addEventMethods ( int cls , int proc2 , int proc3 , int drawRectProc , int hitTestProc , int needsDisplayInRectProc ) { } void addFrameMethods ( int cls , int setFrameOriginProc , int setFrameSizeProc ) { } void addAccessibilityMethods ( int cls , int proc2 , int proc3 , int proc4 , int accessibilityHitTestProc ) { } int registerCellSubclass ( int cellClass , int size , int align , byte [ ] types ) { } void initClasses ( ) { } NSFont getFont ( int cls , int sel ) { } void initFonts ( ) { } public int internal_new_GC ( GCData data ) { } public void internal_dispose_GC ( int context , GCData data ) { } static boolean isValidClass ( Class clazz ) { } boolean isValidThread ( ) { } public boolean post ( Event event ) { synchronized ( Device . class ) { if ( isDisposed ( ) ) error ( ERROR_DEVICE_DISPOSED ) ; if ( event == null ) error ( ERROR_NULL_ARGUMENT ) ; if ( ! ( eventSourceDelaySet ) ) { OS . CGSetLocalEventsSuppressionInterval ( 0.0 ) ; OS . CGEnableEventStateCombining ( 1 ) ; OS . CGSetLocalEventsFilterDuringSuppressionState ( ( ( ( OS . kCGEventFilterMaskPermitLocalKeyboardEvents ) | ( OS . kCGEventFilterMaskPermitLocalMouseEvents ) ) | ( OS . kCGEventFilterMaskPermitSystemDefinedEvents ) ) , kCGEventSuppressionStateSuppressionInterval ) ; OS . CGSetLocalEventsFilterDuringSuppressionState ( ( ( ( OS . kCGEventFilterMaskPermitLocalKeyboardEvents ) | ( OS . kCGEventFilterMaskPermitLocalMouseEvents ) ) | ( OS . kCGEventFilterMaskPermitSystemDefinedEvents ) ) , kCGEventSuppressionStateRemoteMouseDrag ) ; eventSourceDelaySet = true ; } int type = event . type ; switch ( type ) { case SWT . KeyDown : case SWT . KeyUp : { short vKey = ( ( short ) ( Display . untranslateKey ( event . keyCode ) ) ) ; if ( vKey == 0 ) { int uchrPtr = 0 ; int currentKbd = OS . TISCopyCurrentKeyboardInputSource ( ) ; int uchrCFData = OS . TISGetInputSourceProperty ( currentKbd , OS . kTISPropertyUnicodeKeyLayoutData ( ) ) ; if ( uchrCFData == 0 ) return false ; uchrPtr = OS . CFDataGetBytePtr ( uchrCFData ) ; if ( uchrPtr == 0 ) return false ; if ( ( OS . CFDataGetLength ( uchrCFData ) ) == 0 ) return false ; int maxStringLength = 256 ; vKey = - 1 ; char [ ] output = new char [ maxStringLength ] ; int [ ] actualStringLength = new int [ 1 ] ; for ( short i = 0 ; i <= 127 ; i ++ ) { OS . UCKeyTranslate ( uchrPtr , i , ( ( short ) ( type == ( SWT . KeyDown ) ? OS . kUCKeyActionDown : OS . kUCKeyActionUp ) ) , 0 , OS . LMGetKbdType ( ) , 0 , deadKeyState , maxStringLength , actualStringLength , output ) ; if ( ( output [ 0 ] ) == ( event . character ) ) { vKey = i ; break ; } } if ( vKey == ( - 1 ) ) { for ( short i = 0 ; i <= 127 ; i ++ ) { OS . UCKeyTranslate ( uchrPtr , i , ( ( short ) ( type == ( SWT . KeyDown ) ? OS . kUCKeyActionDown : OS . kUCKeyActionUp ) ) , shiftKey , OS . LMGetKbdType ( ) , 0 , deadKeyState , maxStringLength , actualStringLength , output ) ; if ( ( output [ 0 ] ) == ( event . character ) ) { vKey = i ; break ; } } } } boolean postUnicode = false ; <START_BUG> if ( vKey == ( - 1 ) ) { <END_BUG> vKey = 0 ; postUnicode = true ; } int eventRef = OS . CGEventCreateKeyboardEvent ( 0 , vKey , ( type == ( SWT . KeyDown ) ) ) ; if ( eventRef != 0 ) { if ( postUnicode ) { char [ ] eventString = new char [ 1 ] ; eventString [ 0 ] = event . character ; OS . CGEventKeyboardSetUnicodeString ( eventRef , eventString . length , eventString ) ; } OS . CGEventPost ( kCGSessionEventTap , eventRef ) ; OS . CFRelease ( eventRef ) ; return true ; } else { return false ; } } case SWT . MouseDown : case SWT . MouseMove : case SWT . MouseUp : { CGPoint mouseCursorPosition = new CGPoint ( ) ; int chord = OS . GetCurrentButtonState ( ) ; mouseCursorPosition . x = event . x ; mouseCursorPosition . y = event . y ; if ( type == ( SWT . MouseMove ) ) { return ( OS . CGPostMouseEvent ( mouseCursorPosition , true , 5 , ( ( chord & 1 ) != 0 ) , ( ( chord & 2 ) != 0 ) , ( ( chord & 4 ) != 0 ) , ( ( chord & 8 ) != 0 ) , ( ( chord & 16 ) != 0 ) ) ) == 0 ; } else { int button = event . button ; if ( ( button < 1 ) || ( button > 5 ) ) return false ; boolean button1 = false ; boolean button2 = false ; boolean button3 = false ; boolean button4 = false ; boolean button5 = false ; switch ( button ) { case 1 : { button1 = type == ( SWT . MouseDown ) ;

Fix:
if ( ( vKey == ( - 1 ) ) && ( ( event . character ) != 0 ) ) {