Buggy code:
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 ( ) { } int getCaretBlinkTime ( ) { } public Rectangle getClientArea ( ) { } public Control getCursorControl ( ) { } public Point getCursorLocation ( ) { } public Point [ ] getCursorSizes ( ) { } public static Display getDefault ( ) { } public Object getData ( String key ) { } public Object getData ( ) { } public int getDismissalAlignment ( ) { } public int getDoubleClickTime ( ) { } public Control getFocusControl ( ) { } static Control GetFocusControl ( NSWindow window ) { } public boolean getHighContrast ( ) { } public int getIconDepth ( ) { } public Point [ ] getIconSizes ( ) { } int getLastEventTime ( ) { } Menu [ ] getMenus ( Decorations shell ) { } int getMessageCount ( ) { } public Monitor [ ] getMonitors ( ) { } NSRect getPrimaryFrame ( ) { } public Monitor getPrimaryMonitor ( ) { } public Shell [ ] getShells ( ) { } public Synchronizer getSynchronizer ( ) { } public Thread getSyncThread ( ) { } public Color getSystemColor ( int id ) { } Color getWidgetColor ( int id ) { } public Cursor getSystemCursor ( int id ) { } 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 ) { } void postEvent ( Event event ) { } public Point map ( Control from , Control to , Point point ) { } public Point map ( Control from , Control to , int x , int y ) { } public Rectangle map ( Control from , Control to , Rectangle rectangle ) { } public Rectangle map ( Control from , Control to , int x , int y , int width , int height ) { } int observerProc ( int observer , int activity , int info ) { } public boolean readAndDispatch ( ) { checkDevice ( ) ; if ( ( ( sendEventCount ) == 0 ) && ( ( loopCount ) == ( ( poolCount ) - 1 ) ) ) removePool ( ) ; addPool ( ) ; ( loopCount ) ++ ; boolean events = false ; try { events |= runSettings ( ) ; events |= runTimers ( ) ; events |= runContexts ( ) ; events |= runPopups ( ) ; NSEvent event = application . nextEventMatchingMask ( 0 , null , NSDefaultRunLoopMode , true ) ; if ( event != null ) { events = true ; application . sendEvent ( event ) ; } events |= runPaint ( ) ; events |= runDeferredEvents ( ) ; if ( ! events ) { <START_BUG> events = runAsyncMessages ( false ) ; <END_BUG> } } finally { removePool ( ) ; ( loopCount ) -- ; if ( ( ( sendEventCount ) == 0 ) && ( ( loopCount ) == ( poolCount ) ) ) addPool ( ) ; } return events ; } static void register ( Display display ) { } protected void release ( ) { } void releaseDisplay ( ) { } void removeContext ( GCData context ) { } public void removeFilter ( int eventType , Listener listener ) { } public void removeListener ( int eventType , Listener listener ) { } Widget removeWidget ( NSObject view ) { } void removeMenu ( Menu menu ) { } void removePool ( ) { } void removePopup ( Menu menu ) { } boolean runAsyncMessages ( boolean all ) { } boolean runContexts ( ) { } boolean runDeferredEvents ( ) { } boolean runPaint ( ) { } boolean runPopups ( ) { } boolean runSettings ( ) { } boolean runTimers ( ) { } void sendEvent ( int eventType , Event event ) { } void sendEvent ( EventTable table , Event event ) { } static NSString getAppName ( ) { } public static void setAppName ( String name ) { } Runnable hoverTimer = new Runnable ( ) { public void run ( ) { } } ; Runnable caretTimer = new Runnable ( ) { public void run ( ) { } } ; Runnable defaultButtonTimer = new Runnable ( ) { public void run ( ) { } } ; void setCurrentCaret ( Caret caret ) { }

Fix:
events = ( isDisposed ( ) ) || ( runAsyncMessages ( false ) ) ;