7179050: [macosx] Make LWAWT be able to run on AppKit thread
authorserb
Fri, 18 Jan 2013 18:17:02 +0400
changeset 15322 3638f33225ec
parent 15321 da912a45f4e6
child 15323 9087838098e6
7179050: [macosx] Make LWAWT be able to run on AppKit thread Summary: Removed irrelevant assertions from the LWAWT native methods Reviewed-by: serb, anthony Contributed-by: petr.pchelko@oracle.com
jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
jdk/src/macosx/native/sun/awt/AWTSurfaceLayers.m
jdk/src/macosx/native/sun/awt/AWTView.m
jdk/src/macosx/native/sun/awt/AWTWindow.m
jdk/src/macosx/native/sun/awt/ApplicationDelegate.m
jdk/src/macosx/native/sun/awt/CClipboard.m
jdk/src/macosx/native/sun/awt/CCursorManager.m
jdk/src/macosx/native/sun/awt/CDesktopPeer.m
jdk/src/macosx/native/sun/awt/CDragSourceContextPeer.m
jdk/src/macosx/native/sun/awt/CImage.m
jdk/src/macosx/native/sun/awt/CInputMethod.m
jdk/src/macosx/native/sun/awt/CMenu.m
jdk/src/macosx/native/sun/awt/CMenuComponent.m
jdk/src/macosx/native/sun/awt/CMenuItem.m
jdk/src/macosx/native/sun/awt/CPopupMenu.m
jdk/src/macosx/native/sun/awt/CTrayIcon.m
jdk/src/macosx/native/sun/awt/CWrapper.m
jdk/src/macosx/native/sun/awt/JavaComponentAccessibility.m
jdk/src/macosx/native/sun/awt/LWCToolkit.m
jdk/src/macosx/native/sun/awt/awt.m
jdk/src/macosx/native/sun/osxapp/ThreadUtilities.h
jdk/src/macosx/native/sun/osxapp/ThreadUtilities.m
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Fri Jan 18 14:17:11 2013 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Fri Jan 18 18:17:02 2013 +0400
@@ -58,7 +58,6 @@
     private static native void nativeRevalidateNSWindowShadow(long nsWindowPtr);
     private static native void nativeSetNSWindowMinimizedIcon(long nsWindowPtr, long nsImage);
     private static native void nativeSetNSWindowRepresentedFilename(long nsWindowPtr, String representedFilename);
-    private static native void nativeSetNSWindowSecurityWarningPositioning(long nsWindowPtr, double x, double y, float biasX, float biasY);
     private static native void nativeSetEnabled(long nsWindowPtr, boolean isEnabled);
     private static native void nativeSynthesizeMouseEnteredExitedEvents();
     private static native void nativeDispose(long nsWindowPtr);
--- a/jdk/src/macosx/native/sun/awt/AWTSurfaceLayers.m	Fri Jan 18 14:17:11 2013 +0400
+++ b/jdk/src/macosx/native/sun/awt/AWTSurfaceLayers.m	Fri Jan 18 18:17:02 2013 +0400
@@ -101,8 +101,7 @@
 JNF_COCOA_ENTER(env);
 
     [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
-        AWT_ASSERT_APPKIT_THREAD;
-        
+
         CALayer *windowLayer = jlong_to_ptr(windowLayerPtr);
         surfaceLayers = [[AWTSurfaceLayers alloc] initWithWindowLayer: windowLayer];
         CFRetain(surfaceLayers);
@@ -127,7 +126,6 @@
   AWTSurfaceLayers *surfaceLayers = OBJC(surfaceLayersPtr);
     
   [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
-      AWT_ASSERT_APPKIT_THREAD;
 
       CGRect rect = CGRectMake(x, y, width, height);
       [surfaceLayers setBounds: rect];
--- a/jdk/src/macosx/native/sun/awt/AWTView.m	Fri Jan 18 14:17:11 2013 +0400
+++ b/jdk/src/macosx/native/sun/awt/AWTView.m	Fri Jan 18 18:17:02 2013 +0400
@@ -1243,8 +1243,7 @@
     jobject cPlatformView = (*env)->NewGlobalRef(env, obj);
 
     [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
-        AWT_ASSERT_APPKIT_THREAD;
-                                           
+
         CALayer *windowLayer = jlong_to_ptr(windowLayerPtr);
         AWTView *view = [[AWTView alloc] initWithRect:rect
                                          platformView:cPlatformView
@@ -1274,8 +1273,7 @@
     NSView *view = (NSView *)jlong_to_ptr(viewPtr);    
 
    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
-       AWT_ASSERT_APPKIT_THREAD;
-       
+
        if (toResize) {
            [view setAutoresizingMask: NSViewHeightSizable | NSViewWidthSizable];
        } else {
@@ -1308,8 +1306,7 @@
     NSWindow *window = [view window];
     
     [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
-            AWT_ASSERT_APPKIT_THREAD;
-        
+
             ret = (jint)[[AWTWindow getNSWindowDisplayID_AppKitThread: window] intValue];
     }];
     
@@ -1336,8 +1333,7 @@
     
     NSView *view = (NSView *)jlong_to_ptr(viewPtr);    
     [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
-        AWT_ASSERT_APPKIT_THREAD;
-        
+
         NSRect viewBounds = [view bounds];
         NSRect frameInWindow = [view convertRect:viewBounds toView:nil];
         rect = [[view window] convertRectToScreen:frameInWindow];
@@ -1366,9 +1362,7 @@
 JNF_COCOA_ENTER(env);
     
     NSView *nsView = OBJC(viewPtr);
-   [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
-       AWT_ASSERT_APPKIT_THREAD;
-       
+   [ThreadUtilities performOnMainThreadWaiting:YES block:^(){       
        NSPoint ptWindowCoords = [[nsView window] mouseLocationOutsideOfEventStream];
        NSPoint ptViewCoords = [nsView convertPoint:ptWindowCoords fromView:nil];
        underMouse = [nsView hitTest:ptViewCoords] != nil;
--- a/jdk/src/macosx/native/sun/awt/AWTWindow.m	Fri Jan 18 14:17:11 2013 +0400
+++ b/jdk/src/macosx/native/sun/awt/AWTWindow.m	Fri Jan 18 18:17:02 2013 +0400
@@ -738,14 +738,12 @@
     __block AWTWindow *window = nil;
 
 JNF_COCOA_ENTER(env);
-AWT_ASSERT_NOT_APPKIT_THREAD;
 
     JNFWeakJObjectWrapper *platformWindow = [JNFWeakJObjectWrapper wrapperWithJObject:obj withEnv:env];
     NSView *contentView = OBJC(contentViewPtr);
     NSRect frameRect = NSMakeRect(x, y, w, h);
 
-    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
-        AWT_ASSERT_APPKIT_THREAD;
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
 
         window = [[AWTWindow alloc] initWithPlatformWindow:platformWindow
                                                   styleBits:styleBits
@@ -770,11 +768,9 @@
 (JNIEnv *env, jclass clazz, jlong windowPtr, jint mask, jint bits)
 {
 JNF_COCOA_ENTER(env);
-AWT_ASSERT_NOT_APPKIT_THREAD;
 
     NSWindow *nsWindow = OBJC(windowPtr);
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
-        AWT_ASSERT_APPKIT_THREAD;
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
 
         AWTWindow *window = (AWTWindow*)[nsWindow delegate];
 
@@ -807,12 +803,10 @@
 (JNIEnv *env, jclass clazz, jlong windowPtr, jlong menuBarPtr)
 {
 JNF_COCOA_ENTER(env);
-AWT_ASSERT_NOT_APPKIT_THREAD;
 
     NSWindow *nsWindow = OBJC(windowPtr);
     CMenuBar *menuBar = OBJC(menuBarPtr);
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
-        AWT_ASSERT_APPKIT_THREAD;
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
 
         AWTWindow *window = (AWTWindow*)[nsWindow delegate];
 
@@ -838,14 +832,12 @@
     jobject ret = NULL;
 
 JNF_COCOA_ENTER(env);
-AWT_ASSERT_NOT_APPKIT_THREAD;
 
     NSWindow *nsWindow = OBJC(windowPtr);
     __block NSRect contentRect = NSZeroRect;
     __block NSRect frame = NSZeroRect;
 
-    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
-        AWT_ASSERT_APPKIT_THREAD;
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
 
         frame = [nsWindow frame];
         contentRect = [NSWindow contentRectForFrameRect:frame styleMask:[nsWindow styleMask]];
@@ -873,14 +865,12 @@
 (JNIEnv *env, jclass clazz, jlong windowPtr, jdouble originX, jdouble originY, jdouble width, jdouble height)
 {
 JNF_COCOA_ENTER(env);
-AWT_ASSERT_NOT_APPKIT_THREAD;
 
     NSRect jrect = NSMakeRect(originX, originY, width, height);
 
     // TODO: not sure we need displayIfNeeded message in our view
     NSWindow *nsWindow = OBJC(windowPtr);
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
-        AWT_ASSERT_APPKIT_THREAD;
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
 
         AWTWindow *window = (AWTWindow*)[nsWindow delegate];
 
@@ -913,7 +903,6 @@
 (JNIEnv *env, jclass clazz, jlong windowPtr, jdouble minW, jdouble minH, jdouble maxW, jdouble maxH)
 {
 JNF_COCOA_ENTER(env);
-AWT_ASSERT_NOT_APPKIT_THREAD;
 
     if (minW < 1) minW = 1;
     if (minH < 1) minH = 1;
@@ -921,8 +910,7 @@
     if (maxH < 1) maxH = 1;
 
     NSWindow *nsWindow = OBJC(windowPtr);
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
-        AWT_ASSERT_APPKIT_THREAD;
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
 
         AWTWindow *window = (AWTWindow*)[nsWindow delegate];
 
@@ -949,12 +937,9 @@
 (JNIEnv *env, jclass clazz, jlong windowPtr)
 {
 JNF_COCOA_ENTER(env);
-AWT_ASSERT_NOT_APPKIT_THREAD;
 
     NSWindow *nsWindow = OBJC(windowPtr);
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
-        AWT_ASSERT_APPKIT_THREAD;
-
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         [nsWindow orderBack:nil];
     }];
 
@@ -970,11 +955,9 @@
 (JNIEnv *env, jclass clazz, jlong windowPtr)
 {
 JNF_COCOA_ENTER(env);
-AWT_ASSERT_NOT_APPKIT_THREAD;
 
     NSWindow *nsWindow = OBJC(windowPtr);
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
-        AWT_ASSERT_APPKIT_THREAD;
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
 
         if (![nsWindow isKeyWindow]) {
             [nsWindow makeKeyAndOrderFront:nsWindow];
@@ -995,7 +978,6 @@
 (JNIEnv *env, jclass clazz, jlong windowPtr, jstring jtitle)
 {
 JNF_COCOA_ENTER(env);
-AWT_ASSERT_NOT_APPKIT_THREAD;
 
     NSWindow *nsWindow = OBJC(windowPtr);
     [nsWindow performSelectorOnMainThread:@selector(setTitle:)
@@ -1016,15 +998,9 @@
 JNF_COCOA_ENTER(env);
 
     NSWindow *nsWindow = OBJC(windowPtr);
-    if ([NSThread isMainThread]) {
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         [nsWindow invalidateShadow];
-    } else {
-        [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
-            AWT_ASSERT_APPKIT_THREAD;
-
-            [nsWindow invalidateShadow];
-        }];
-    }
+    }];
 
 JNF_COCOA_EXIT(env);
 }
@@ -1060,13 +1036,10 @@
 (JNIEnv *env, jclass clazz, jlong windowPtr, jlong nsImagePtr)
 {
 JNF_COCOA_ENTER(env);
-AWT_ASSERT_NOT_APPKIT_THREAD;
 
     NSWindow *nsWindow = OBJC(windowPtr);
     NSImage *image = OBJC(nsImagePtr);
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
-        AWT_ASSERT_APPKIT_THREAD;
-
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         [nsWindow setMiniwindowImage:image];
     }];
 
@@ -1082,13 +1055,10 @@
 (JNIEnv *env, jclass clazz, jlong windowPtr, jstring filename)
 {
 JNF_COCOA_ENTER(env);
-AWT_ASSERT_NOT_APPKIT_THREAD;
 
     NSWindow *nsWindow = OBJC(windowPtr);
     NSURL *url = (filename == NULL) ? nil : [NSURL fileURLWithPath:JNFNormalizedNSStringForPath(env, filename)];
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
-        AWT_ASSERT_APPKIT_THREAD;
-
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         [nsWindow setRepresentedURL:url];
     }];
 
@@ -1097,22 +1067,6 @@
 
 /*
  * Class:     sun_lwawt_macosx_CPlatformWindow
- * Method:    nativeSetNSWindowSecurityWarningPositioning
- * Signature: (JDDFF)V
- */
-JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowSecurityWarningPositioning
-(JNIEnv *env, jclass clazz, jlong windowPtr, jdouble x, jdouble y, jfloat biasX, jfloat biasY)
-{
-JNF_COCOA_ENTER(env);
-AWT_ASSERT_NOT_APPKIT_THREAD;
-
-    [JNFException raise:env as:kRuntimeException reason:"unimplemented"];
-
-JNF_COCOA_EXIT(env);
-}
-
-/*
- * Class:     sun_lwawt_macosx_CPlatformWindow
  * Method:    nativeGetTopmostPlatformWindowUnderMouse
  * Signature: (J)V
  */
@@ -1144,10 +1098,8 @@
 (JNIEnv *env, jclass clazz)
 {
     JNF_COCOA_ENTER(env);
-    AWT_ASSERT_NOT_APPKIT_THREAD;
 
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
-        AWT_ASSERT_APPKIT_THREAD;
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         [AWTWindow synthesizeMouseEnteredExitedEventsForAllWindows];
     }];
 
@@ -1168,7 +1120,7 @@
     SEL toggleFullScreenSelector = @selector(toggleFullScreen:);
     if (![nsWindow respondsToSelector:toggleFullScreenSelector]) return;
 
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         [nsWindow performSelector:toggleFullScreenSelector withObject:nil];
     }];
 
@@ -1181,7 +1133,7 @@
 JNF_COCOA_ENTER(env);
 
     NSWindow *nsWindow = OBJC(windowPtr);
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         AWTWindow *window = (AWTWindow*)[nsWindow delegate];
 
         [window setEnabled: isEnabled];
@@ -1196,7 +1148,7 @@
 JNF_COCOA_ENTER(env);
 
     NSWindow *nsWindow = OBJC(windowPtr);
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         AWTWindow *window = (AWTWindow*)[nsWindow delegate];
 
         if ([AWTWindow lastKeyWindow] == window) {
--- a/jdk/src/macosx/native/sun/awt/ApplicationDelegate.m	Fri Jan 18 14:17:11 2013 +0400
+++ b/jdk/src/macosx/native/sun/awt/ApplicationDelegate.m	Fri Jan 18 18:17:02 2013 +0400
@@ -515,10 +515,9 @@
 JNIEXPORT void JNICALL Java_com_apple_eawt_Application_nativeInitializeApplicationDelegate
 (JNIEnv *env, jclass clz)
 {
-AWT_ASSERT_NOT_APPKIT_THREAD;
 JNF_COCOA_ENTER(env);
     // Force initialization to happen on AppKit thread!
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         [ApplicationDelegate sharedDelegate];
     }];
 JNF_COCOA_EXIT(env);
@@ -532,10 +531,9 @@
 JNIEXPORT void JNICALL Java_com_apple_eawt__1AppEventHandler_nativeOpenCocoaAboutWindow
 (JNIEnv *env, jclass clz)
 {
-AWT_ASSERT_NOT_APPKIT_THREAD;
 JNF_COCOA_ENTER(env);
 
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         [NSApp orderFrontStandardAboutPanel:nil];
     }];
 
@@ -550,10 +548,9 @@
 JNIEXPORT void JNICALL Java_com_apple_eawt__1AppEventHandler_nativeReplyToAppShouldTerminate
 (JNIEnv *env, jclass clz, jboolean doTerminate)
 {
-AWT_ASSERT_NOT_APPKIT_THREAD;
 JNF_COCOA_ENTER(env);
 
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         [NSApp replyToApplicationShouldTerminate:doTerminate];
     }];
 
@@ -568,7 +565,6 @@
 JNIEXPORT void JNICALL Java_com_apple_eawt__1AppEventHandler_nativeRegisterForNotification
 (JNIEnv *env, jclass clz, jint notificationType)
 {
-AWT_ASSERT_NOT_APPKIT_THREAD;
 JNF_COCOA_ENTER(env);
     [ThreadUtilities performOnMainThread:@selector(_registerForNotification:)
                                 onObject:[ApplicationDelegate class]
@@ -586,13 +582,10 @@
 JNIEXPORT void JNICALL Java_com_apple_eawt__1AppDockIconHandler_nativeSetDockMenu
 (JNIEnv *env, jclass clz, jlong nsMenuPtr)
 {
-AWT_ASSERT_NOT_APPKIT_THREAD;
 JNF_COCOA_ENTER(env);
 
     NSMenu *menu = (NSMenu *)jlong_to_ptr(nsMenuPtr);
-    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
-        AWT_ASSERT_APPKIT_THREAD;
-
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
         [ApplicationDelegate sharedDelegate].fDockMenu = menu;
     }];
 
@@ -607,14 +600,13 @@
 JNIEXPORT void JNICALL Java_com_apple_eawt__1AppDockIconHandler_nativeSetDockIconImage
 (JNIEnv *env, jclass clz, jlong nsImagePtr)
 {
-AWT_ASSERT_NOT_APPKIT_THREAD;
 JNF_COCOA_ENTER(env);
 
     NSImage *_image = (NSImage *)jlong_to_ptr(nsImagePtr);
-    [JNFRunLoop performOnMainThread:@selector(_setDockIconImage:)
-                                 on:[ApplicationDelegate class]
-                         withObject:_image
-                      waitUntilDone:NO];
+    [ThreadUtilities performOnMainThread:@selector(_setDockIconImage:)
+                                      on:[ApplicationDelegate class]
+                              withObject:_image
+                           waitUntilDone:NO];
 
 JNF_COCOA_EXIT(env);
 }
@@ -629,12 +621,9 @@
 {
     __block NSImage *image = nil;
 
-AWT_ASSERT_NOT_APPKIT_THREAD;
 JNF_COCOA_ENTER(env);
 
-    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
-        AWT_ASSERT_APPKIT_THREAD;
-
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
         image = [ApplicationDelegate _dockIconImage];
         CFRetain(image);
     }];
@@ -652,13 +641,10 @@
 JNIEXPORT void JNICALL Java_com_apple_eawt__1AppDockIconHandler_nativeSetDockIconBadge
 (JNIEnv *env, jclass clz, jstring badge)
 {
-AWT_ASSERT_NOT_APPKIT_THREAD;
 JNF_COCOA_ENTER(env);
 
     NSString *badgeString = JNFJavaToNSString(env, badge);
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
-        AWT_ASSERT_APPKIT_THREAD;
-
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         NSDockTile *dockTile = [NSApp dockTile];
         [dockTile setBadgeLabel:badgeString];
         [dockTile display];
@@ -675,12 +661,9 @@
 JNIEXPORT void JNICALL Java_com_apple_eawt__1AppMiscHandlers_nativeRequestActivation
 (JNIEnv *env, jclass clz, jboolean allWindows)
 {
-AWT_ASSERT_NOT_APPKIT_THREAD;
 JNF_COCOA_ENTER(env);
 
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
-        AWT_ASSERT_APPKIT_THREAD;
-
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         NSApplicationActivationOptions options = allWindows ? NSApplicationActivateAllWindows : 0;
         options |= NSApplicationActivateIgnoringOtherApps; // without this, nothing happens!
         [[NSRunningApplication currentApplication] activateWithOptions:options];
@@ -697,12 +680,9 @@
 JNIEXPORT void JNICALL Java_com_apple_eawt__1AppMiscHandlers_nativeRequestUserAttention
 (JNIEnv *env, jclass clz, jboolean critical)
 {
-AWT_ASSERT_NOT_APPKIT_THREAD;
 JNF_COCOA_ENTER(env);
 
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
-        AWT_ASSERT_APPKIT_THREAD;
-
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         [NSApp requestUserAttention:critical ? NSCriticalRequest : NSInformationalRequest];
     }];
 
@@ -717,13 +697,12 @@
 JNIEXPORT void JNICALL Java_com_apple_eawt__1AppMiscHandlers_nativeOpenHelpViewer
 (JNIEnv *env, jclass clz)
 {
-AWT_ASSERT_NOT_APPKIT_THREAD;
 JNF_COCOA_ENTER(env);
 
-    [JNFRunLoop performOnMainThread:@selector(showHelp:)
-                                 on:NSApp
-                         withObject:nil
-                      waitUntilDone:NO];
+    [ThreadUtilities performOnMainThread:@selector(showHelp:)
+                                      on:NSApp
+                              withObject:nil
+                           waitUntilDone:NO];
 
 JNF_COCOA_EXIT(env);
 }
@@ -736,7 +715,6 @@
 JNIEXPORT void JNICALL Java_com_apple_eawt__1AppMiscHandlers_nativeEnableSuddenTermination
 (JNIEnv *env, jclass clz)
 {
-AWT_ASSERT_NOT_APPKIT_THREAD;
 JNF_COCOA_ENTER(env);
 
     [[NSProcessInfo processInfo] enableSuddenTermination]; // Foundation thread-safe
@@ -752,7 +730,6 @@
 JNIEXPORT void JNICALL Java_com_apple_eawt__1AppMiscHandlers_nativeDisableSuddenTermination
 (JNIEnv *env, jclass clz)
 {
-AWT_ASSERT_NOT_APPKIT_THREAD;
 JNF_COCOA_ENTER(env);
 
     [[NSProcessInfo processInfo] disableSuddenTermination]; // Foundation thread-safe
@@ -768,12 +745,9 @@
 JNIEXPORT void JNICALL Java_com_apple_eawt__1AppMenuBarHandler_nativeSetMenuState
 (JNIEnv *env, jclass clz, jint menuID, jboolean visible, jboolean enabled)
 {
-AWT_ASSERT_NOT_APPKIT_THREAD;
 JNF_COCOA_ENTER(env);
 
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
-        AWT_ASSERT_APPKIT_THREAD;
-
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         ApplicationDelegate *delegate = [ApplicationDelegate sharedDelegate];
         switch (menuID) {
             case com_apple_eawt__AppMenuBarHandler_MENU_ABOUT:
@@ -796,12 +770,10 @@
 JNIEXPORT void JNICALL Java_com_apple_eawt__1AppMenuBarHandler_nativeSetDefaultMenuBar
 (JNIEnv *env, jclass clz, jlong cMenuBarPtr)
 {
-AWT_ASSERT_NOT_APPKIT_THREAD;
 JNF_COCOA_ENTER(env);
 
     CMenuBar *menu = (CMenuBar *)jlong_to_ptr(cMenuBarPtr);
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
-        AWT_ASSERT_APPKIT_THREAD;
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         [ApplicationDelegate sharedDelegate].fDefaultMenuBar = menu;
     }];
 
--- a/jdk/src/macosx/native/sun/awt/CClipboard.m	Fri Jan 18 14:17:11 2013 +0400
+++ b/jdk/src/macosx/native/sun/awt/CClipboard.m	Fri Jan 18 18:17:02 2013 +0400
@@ -109,7 +109,6 @@
 }
 
 - (void) javaDeclareTypes:(NSArray *)inTypes withOwner:(jobject)inClipboard jniEnv:(JNIEnv *)inEnv {
-    AWT_ASSERT_NOT_APPKIT_THREAD;
 
     //NSLog(@"CClipboard javaDeclareTypes %@ withOwner", inTypes);
 
@@ -134,7 +133,6 @@
 
 
 - (NSArray *) javaGetTypes {
-    AWT_ASSERT_NOT_APPKIT_THREAD;
 
     NSMutableArray *args = [NSMutableArray arrayWithCapacity:1];
     [ThreadUtilities performOnMainThread:@selector(_nativeGetTypes:) onObject:self withObject:args waitUntilDone:YES awtMode:YES];
@@ -152,7 +150,6 @@
 }
 
 - (void) javaSetData:(NSData *)inData forType:(NSString *) inFormat {
-    AWT_ASSERT_NOT_APPKIT_THREAD;
 
     CClipboardUpdate *newUpdate = [[CClipboardUpdate alloc] initWithData:inData withFormat:inFormat];
     [ThreadUtilities performOnMainThread:@selector(_nativeSetData:) onObject:self withObject:newUpdate waitUntilDone:YES awtMode:YES];
@@ -171,7 +168,6 @@
 }
 
 - (NSData *) javaGetDataForType:(NSString *) inFormat {
-    AWT_ASSERT_NOT_APPKIT_THREAD;
 
     NSMutableArray *args = [NSMutableArray arrayWithObject:inFormat];
     [ThreadUtilities performOnMainThread:@selector(_nativeGetDataForType:) onObject:self withObject:args waitUntilDone:YES awtMode:YES];
--- a/jdk/src/macosx/native/sun/awt/CCursorManager.m	Fri Jan 18 14:17:11 2013 +0400
+++ b/jdk/src/macosx/native/sun/awt/CCursorManager.m	Fri Jan 18 18:17:02 2013 +0400
@@ -74,7 +74,6 @@
 (JNIEnv *env, jclass class, jint type, jstring name)
 {
 JNF_COCOA_ENTER(env);
-AWT_ASSERT_NOT_APPKIT_THREAD;
 
     NSString *cursorName = JNFJavaToNSString(env, name);
     SEL cursorSelector = (type == sun_lwawt_macosx_CCursorManager_NAMED_CURSOR) ? lookupCursorSelectorForName(cursorName) : lookupCursorSelectorForType(type);
@@ -87,9 +86,7 @@
         [JNFException raise:env as:kNoSuchMethodException reason:"missing NSCursor selector"];
     }
 
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
-        AWT_ASSERT_APPKIT_THREAD;
-
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         setCursorOnAppKitThread([[NSCursor class] performSelector:cursorSelector]);
     }];
 
@@ -101,12 +98,9 @@
 (JNIEnv *env, jclass class, jlong imgPtr, jdouble x, jdouble y)
 {
 JNF_COCOA_ENTER(env);
-AWT_ASSERT_NOT_APPKIT_THREAD;
     NSImage *image = (NSImage *)jlong_to_ptr(imgPtr);
 
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
-        AWT_ASSERT_APPKIT_THREAD;
-
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         NSCursor *cursor = [[NSCursor alloc] initWithImage:image
                                                    hotSpot:(NSPoint){ x, y }];
         setCursorOnAppKitThread(cursor);
@@ -127,8 +121,6 @@
     __block NSPoint pt = NSZeroPoint;
     
     [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
-            AWT_ASSERT_APPKIT_THREAD;
-        
             pt = ConvertNSScreenPoint(env, [NSEvent mouseLocation]);
     }];
     
@@ -144,13 +136,11 @@
 Java_sun_lwawt_macosx_CCursorManager_nativeSetAllowsCursorSetInBackground
 (JNIEnv *env, jclass class, jboolean allows)
 {
-
 JNF_COCOA_ENTER(env);
-AWT_ASSERT_NOT_APPKIT_THREAD;
 
     SEL allowsSetInBackground_SEL = @selector(javaSetAllowsCursorSetInBackground:);
     if ([[NSCursor class] respondsToSelector:allowsSetInBackground_SEL]) {
-        [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
+        [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
             NSMethodSignature *allowsSetInBackground_sig =
                 [[NSCursor class] methodSignatureForSelector:allowsSetInBackground_SEL];
             NSInvocation *invocation =
--- a/jdk/src/macosx/native/sun/awt/CDesktopPeer.m	Fri Jan 18 14:17:11 2013 +0400
+++ b/jdk/src/macosx/native/sun/awt/CDesktopPeer.m	Fri Jan 18 18:17:02 2013 +0400
@@ -36,8 +36,6 @@
 JNIEXPORT jint JNICALL Java_sun_lwawt_macosx_CDesktopPeer__1lsOpenURI
 (JNIEnv *env, jclass clz, jstring uri)
 {
-    // AWT_ASSERT_ANY_THREAD
-
     OSStatus status = noErr;
 JNF_COCOA_ENTER(env);
 
@@ -63,8 +61,6 @@
 JNIEXPORT jint JNICALL Java_sun_lwawt_macosx_CDesktopPeer__1lsOpenFile
 (JNIEnv *env, jclass clz, jstring jpath, jboolean print)
 {
-    // AWT_ASSERT_ANY_THREAD
-
     OSStatus status = noErr;
 JNF_COCOA_ENTER(env);
 
--- a/jdk/src/macosx/native/sun/awt/CDragSourceContextPeer.m	Fri Jan 18 14:17:11 2013 +0400
+++ b/jdk/src/macosx/native/sun/awt/CDragSourceContextPeer.m	Fri Jan 18 18:17:02 2013 +0400
@@ -46,7 +46,7 @@
     __block CDragSource* dragSource = nil;
 
 JNF_COCOA_ENTER(env);
-    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
         dragSource = [[CDragSource alloc] init:jthis component:jcomponent peer:jpeer control:controlObj
             transferable:jtransferable triggerEvent:jtrigger dragPosX:jdragposx
             dragPosY:jdragposy modifiers:jextmodifiers clickCount:jclickcount timeStamp:jtimestamp
@@ -103,7 +103,7 @@
 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CDragSourceContextPeer_setNativeCursor
   (JNIEnv *env, jobject jthis, jlong nativeDragSourceVal, jobject jcursor, jint jcursortype)
 {
-    AWT_ASSERT_NOT_APPKIT_THREAD;
+   //AWT_ASSERT_NOT_APPKIT_THREAD;
 
 //JNF_COCOA_ENTER(env);
 //    jobject gCursor = JNFNewGlobalRef(env, jcursor);
--- a/jdk/src/macosx/native/sun/awt/CImage.m	Fri Jan 18 14:17:11 2013 +0400
+++ b/jdk/src/macosx/native/sun/awt/CImage.m	Fri Jan 18 18:17:02 2013 +0400
@@ -108,7 +108,6 @@
     jlong result = 0L;
 
 JNF_COCOA_ENTER(env);
-AWT_ASSERT_ANY_THREAD;
 
     NSBitmapImageRep* imageRep = CImage_CreateImageRep(env, buffer, width, height);
     if (imageRep) {
@@ -139,7 +138,6 @@
     jlong result = 0L;
 
 JNF_COCOA_ENTER(env);
-AWT_ASSERT_ANY_THREAD;
 
     jsize num = (*env)->GetArrayLength(env, buffers);
     NSMutableArray * reps = [NSMutableArray arrayWithCapacity: num];
@@ -187,7 +185,6 @@
     NSImage *image = nil;
 
 JNF_COCOA_ENTER(env);
-AWT_ASSERT_ANY_THREAD;
 
     IconRef iconRef;
     if (noErr == GetIconRef(kOnSystemDisk, kSystemIconsCreator, selector, &iconRef)) {
@@ -212,7 +209,6 @@
     NSImage *image = nil;
 
 JNF_COCOA_ENTER(env);
-AWT_ASSERT_ANY_THREAD;
 
     NSString *path = JNFNormalizedNSStringForPath(env, file);
     image = [[NSImage alloc] initByReferencingFile:path];
@@ -234,10 +230,9 @@
     __block NSImage *image = nil;
 
 JNF_COCOA_ENTER(env);
-AWT_ASSERT_ANY_THREAD;
 
     NSString *path = JNFNormalizedNSStringForPath(env, file);
-    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
         image = [[NSWorkspace sharedWorkspace] iconForFile:path];
         [image setScalesWhenResized:TRUE];
         if (image) CFRetain(image); // GC
@@ -259,7 +254,6 @@
     NSImage *image = nil;
 
 JNF_COCOA_ENTER(env);
-AWT_ASSERT_ANY_THREAD;
 
     image = [NSImage imageNamed:JNFJavaToNSString(env, name)];
     if (image) CFRetain(image); // GC
@@ -278,7 +272,6 @@
 (JNIEnv *env, jclass klass, jlong nsImgPtr, jintArray buffer, jint w, jint h)
 {
 JNF_COCOA_ENTER(env);
-AWT_ASSERT_ANY_THREAD;
 
     NSImage *img = (NSImage *)jlong_to_ptr(nsImgPtr);
     jint *dst = (*env)->GetPrimitiveArrayCritical(env, buffer, NULL);
@@ -301,7 +294,6 @@
     jobject size = NULL;
 
 JNF_COCOA_ENTER(env);
-AWT_ASSERT_ANY_THREAD;
 
     size = NSToJavaSize(env, [(NSImage *)jlong_to_ptr(nsImgPtr) size]);
 
--- a/jdk/src/macosx/native/sun/awt/CInputMethod.m	Fri Jan 18 14:17:11 2013 +0400
+++ b/jdk/src/macosx/native/sun/awt/CInputMethod.m	Fri Jan 18 18:17:02 2013 +0400
@@ -153,7 +153,7 @@
     __block NSString *keyboardInfo = NULL;
 JNF_COCOA_ENTER(env);
 
-    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
         keyboardInfo = [inputMethodController performSelector:@selector(currentInputMethodName)];
         [keyboardInfo retain];
     }];
@@ -177,7 +177,7 @@
 JNF_COCOA_ENTER(env);
     AWTView *view = (AWTView *)jlong_to_ptr(nativePeer);
     JNFJObjectWrapper *inputMethodWrapper = [[JNFJObjectWrapper alloc] initWithJObject:inputMethod withEnv:env];
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         [CInputMethod _nativeNotifyPeerWithView:view inputMethod:inputMethodWrapper];
     }];
 
@@ -196,7 +196,7 @@
 JNF_COCOA_ENTER(env);
    AWTView *view = (AWTView *)jlong_to_ptr(nativePeer);
 
-   [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
+   [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         [CInputMethod _nativeEndComposition:view];
     }];
 
@@ -216,7 +216,7 @@
     __block NSString *isoAbbreviation;
 JNF_COCOA_ENTER(env);
 
-    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
         isoAbbreviation = (NSString *) [inputMethodController performSelector:@selector(currentInputMethodLocale)];
         [isoAbbreviation retain];
     }];
@@ -259,7 +259,7 @@
     NSString *localeStr = JNFJavaToNSString(env, locale);
     [localeStr retain];
 
-    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
         [CInputMethod setKeyboardLayout:localeStr];
     }];
 
@@ -293,7 +293,7 @@
     __block NSArray *selectableArray = nil;
 JNF_COCOA_ENTER(env);
 
-    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
         selectableArray = (NSArray *)[inputMethodController performSelector:@selector(availableInputMethodLocales)];
         [selectableArray retain];
     }];
--- a/jdk/src/macosx/native/sun/awt/CMenu.m	Fri Jan 18 14:17:11 2013 +0400
+++ b/jdk/src/macosx/native/sun/awt/CMenu.m	Fri Jan 18 18:17:02 2013 +0400
@@ -55,12 +55,10 @@
 //- (void)finalize { [super finalize]; }
 
 - (void)addJavaSubmenu:(CMenu *)submenu {
-AWT_ASSERT_NOT_APPKIT_THREAD;
     [ThreadUtilities performOnMainThread:@selector(addNativeItem_OnAppKitThread:) onObject:self withObject:submenu waitUntilDone:YES awtMode:YES];
 }
 
 - (void)addJavaMenuItem:(CMenuItem *)theMenuItem {
-AWT_ASSERT_NOT_APPKIT_THREAD;
     [ThreadUtilities performOnMainThread:@selector(addNativeItem_OnAppKitThread:) onObject:self withObject:theMenuItem waitUntilDone:YES awtMode:YES];
 }
 
@@ -70,7 +68,6 @@
 }
 
 - (void)setJavaMenuTitle:(NSString *)title {
-AWT_ASSERT_NOT_APPKIT_THREAD;
 
     if (title) {
         [ThreadUtilities performOnMainThread:@selector(setNativeMenuTitle_OnAppKitThread:) onObject:self withObject:title waitUntilDone:YES awtMode:YES];
@@ -95,7 +92,6 @@
 }
 
 - (void)deleteJavaItem:(jint)index {
-AWT_ASSERT_NOT_APPKIT_THREAD;
 
     [ThreadUtilities performOnMainThread:@selector(deleteNativeJavaItem_OnAppKitThread:) onObject:self withObject:[NSNumber numberWithInt:index] waitUntilDone:YES awtMode:YES];
 }
--- a/jdk/src/macosx/native/sun/awt/CMenuComponent.m	Fri Jan 18 14:17:11 2013 +0400
+++ b/jdk/src/macosx/native/sun/awt/CMenuComponent.m	Fri Jan 18 18:17:02 2013 +0400
@@ -80,10 +80,10 @@
 {
 JNF_COCOA_ENTER(env);
 
-    [JNFRunLoop performOnMainThread:@selector(disposer)
-                                 on:((id)jlong_to_ptr(menuItemObj))
-                         withObject:nil
-                      waitUntilDone:NO];
+    [ThreadUtilities performOnMainThread:@selector(disposer)
+                                      on:((id)jlong_to_ptr(menuItemObj))
+                              withObject:nil
+                           waitUntilDone:NO];
 
 JNF_COCOA_EXIT(env);
 }
--- a/jdk/src/macosx/native/sun/awt/CMenuItem.m	Fri Jan 18 14:17:11 2013 +0400
+++ b/jdk/src/macosx/native/sun/awt/CMenuItem.m	Fri Jan 18 18:17:02 2013 +0400
@@ -104,7 +104,6 @@
 }
 
 - (void) setJavaLabel:(NSString *)theLabel shortcut:(NSString *)theKeyEquivalent modifierMask:(jint)modifiers {
-AWT_ASSERT_NOT_APPKIT_THREAD;
 
     NSUInteger modifierMask = 0;
 
@@ -126,8 +125,7 @@
         modifierMask = JavaModifiersToNsKeyModifiers(modifiers, NO);
     }
 
-    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
-        AWT_ASSERT_APPKIT_THREAD;
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
         [fMenuItem setKeyEquivalent:theKeyEquivalent];
         [fMenuItem setKeyEquivalentModifierMask:modifierMask];
         [fMenuItem setTitle:theLabel];
@@ -135,32 +133,23 @@
 }
 
 - (void) setJavaImage:(NSImage *)theImage {
-AWT_ASSERT_NOT_APPKIT_THREAD;
 
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
-        AWT_ASSERT_APPKIT_THREAD;
-
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         [fMenuItem setImage:theImage];
     }];
 }
 
 - (void) setJavaToolTipText:(NSString *)theText {
-AWT_ASSERT_NOT_APPKIT_THREAD;
 
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
-        AWT_ASSERT_APPKIT_THREAD;
-
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         [fMenuItem setToolTip:theText];
     }];
 }
 
 
 - (void)setJavaEnabled:(BOOL) enabled {
-AWT_ASSERT_NOT_APPKIT_THREAD;
 
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
-        AWT_ASSERT_APPKIT_THREAD;
-
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         @synchronized(self) {
             fIsEnabled = enabled;
 
@@ -173,7 +162,6 @@
 }
 
 - (BOOL)isEnabled {
-    // AWT_ASSERT_ANY_THREAD;
 
     BOOL enabled = NO;
     @synchronized(self) {
@@ -184,11 +172,8 @@
 
 
 - (void)setJavaState:(BOOL)newState {
-AWT_ASSERT_NOT_APPKIT_THREAD;
 
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
-AWT_ASSERT_APPKIT_THREAD;
-
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         [fMenuItem setState:(newState ? NSOnState : NSOffState)];
     }];
 }
--- a/jdk/src/macosx/native/sun/awt/CPopupMenu.m	Fri Jan 18 14:17:11 2013 +0400
+++ b/jdk/src/macosx/native/sun/awt/CPopupMenu.m	Fri Jan 18 18:17:02 2013 +0400
@@ -64,7 +64,7 @@
 
     jobject cPeerObjGlobal = JNFNewGlobalRef(env, peer);
 
-    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
         aCPopupMenu = [[CPopupMenu alloc] initWithPeer:cPeerObjGlobal];
         CFRetain(aCPopupMenu);
         [aCPopupMenu release];
@@ -82,7 +82,7 @@
 
     CPopupMenu* cPopupMenu = (CPopupMenu*)jlong_to_ptr(menuPtr);
 
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         NSPoint loc = ConvertNSScreenPoint(env, NSMakePoint(x, y));
 
         [[cPopupMenu menu] popUpMenuPositioningItem: nil
--- a/jdk/src/macosx/native/sun/awt/CTrayIcon.m	Fri Jan 18 14:17:11 2013 +0400
+++ b/jdk/src/macosx/native/sun/awt/CTrayIcon.m	Fri Jan 18 18:17:02 2013 +0400
@@ -303,10 +303,9 @@
     __block AWTTrayIcon *trayIcon = nil;
 
 JNF_COCOA_ENTER(env);
-AWT_ASSERT_NOT_APPKIT_THREAD;
 
     jobject thePeer = JNFNewGlobalRef(env, peer);
-    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
         trayIcon = [[AWTTrayIcon alloc] initWithPeer:thePeer];
     }];
 
@@ -334,11 +333,10 @@
 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CTrayIcon_nativeSetToolTip
 (JNIEnv *env, jobject self, jlong model, jstring jtooltip) {
 JNF_COCOA_ENTER(env);
-AWT_ASSERT_NOT_APPKIT_THREAD;
 
     AWTTrayIcon *icon = jlong_to_ptr(model);
     NSString *tooltip = JNFJavaToNSString(env, jtooltip);
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         [icon setTooltip:tooltip];
     }];
 
@@ -353,10 +351,9 @@
 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CTrayIcon_setNativeImage
 (JNIEnv *env, jobject self, jlong model, jlong imagePtr, jboolean autosize) {
 JNF_COCOA_ENTER(env);
-AWT_ASSERT_NOT_APPKIT_THREAD;
 
     AWTTrayIcon *icon = jlong_to_ptr(model);
-    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
         [icon setImage:jlong_to_ptr(imagePtr) sizing:autosize];
     }];
 
@@ -369,13 +366,10 @@
     jobject jpt = NULL;
 
 JNF_COCOA_ENTER(env);
-AWT_ASSERT_NOT_APPKIT_THREAD;
 
     __block NSPoint pt = NSZeroPoint;
     AWTTrayIcon *icon = jlong_to_ptr(model);
-    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
-        AWT_ASSERT_APPKIT_THREAD;
-
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
         NSPoint loc = [icon getLocationOnScreen];
         pt = ConvertNSScreenPoint(env, loc);
     }];
--- a/jdk/src/macosx/native/sun/awt/CWrapper.m	Fri Jan 18 14:17:11 2013 +0400
+++ b/jdk/src/macosx/native/sun/awt/CWrapper.m	Fri Jan 18 18:17:02 2013 +0400
@@ -46,7 +46,7 @@
 JNF_COCOA_ENTER(env);
 
     id obj = (id)jlong_to_ptr(objectPtr);
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         CFRelease(obj);
     }];
 
@@ -66,10 +66,10 @@
 JNF_COCOA_ENTER(env);
 
     NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
-    [JNFRunLoop performOnMainThread:@selector(makeKeyAndOrderFront:)
-                                 on:window
-                         withObject:nil
-                      waitUntilDone:NO];
+    [ThreadUtilities performOnMainThread:@selector(makeKeyAndOrderFront:)
+                                      on:window
+                              withObject:nil
+                           waitUntilDone:NO];
 
 JNF_COCOA_EXIT(env);
 }
@@ -86,10 +86,10 @@
 JNF_COCOA_ENTER(env);
 
     NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
-    [JNFRunLoop performOnMainThread:@selector(makeKeyWindow)
-                                 on:window
-                         withObject:nil
-                      waitUntilDone:NO];
+    [ThreadUtilities performOnMainThread:@selector(makeKeyWindow)
+                                      on:window
+                              withObject:nil
+                           waitUntilDone:NO];
 
 JNF_COCOA_EXIT(env);
 }
@@ -106,10 +106,10 @@
 JNF_COCOA_ENTER(env);
 
     NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
-    [JNFRunLoop performOnMainThread:@selector(makeMainWindow)
-                                 on:window
-                         withObject:nil
-                      waitUntilDone:NO];
+    [ThreadUtilities performOnMainThread:@selector(makeMainWindow)
+                                      on:window
+                              withObject:nil
+                           waitUntilDone:NO];
 
 JNF_COCOA_EXIT(env);
 }
@@ -128,7 +128,7 @@
 JNF_COCOA_ENTER(env);
 
     NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
-    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
         canBecomeMainWindow = [window canBecomeMainWindow];
     }];
 
@@ -151,7 +151,7 @@
 JNF_COCOA_ENTER(env);
 
     NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
-    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
         isKeyWindow = [window isKeyWindow];
     }];
 
@@ -172,10 +172,10 @@
 JNF_COCOA_ENTER(env);
 
     NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
-    [JNFRunLoop performOnMainThread:@selector(orderFront:)
-                                 on:window
-                         withObject:window
-                      waitUntilDone:NO];
+    [ThreadUtilities performOnMainThread:@selector(orderFront:)
+                                      on:window
+                              withObject:window
+                           waitUntilDone:NO];
 
 JNF_COCOA_EXIT(env);
 }
@@ -192,10 +192,10 @@
 JNF_COCOA_ENTER(env);
 
     NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
-    [JNFRunLoop performOnMainThread:@selector(orderOut:)
-                                 on:window
-                         withObject:window
-                      waitUntilDone:NO];
+    [ThreadUtilities performOnMainThread:@selector(orderOut:)
+                                      on:window
+                              withObject:window
+                           waitUntilDone:NO];
 
 JNF_COCOA_EXIT(env);
 }
@@ -212,10 +212,10 @@
 JNF_COCOA_ENTER(env);
 
     NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
-    [JNFRunLoop performOnMainThread:@selector(orderFrontRegardless)
-                                 on:window
-                         withObject:nil
-                      waitUntilDone:NO];
+    [ThreadUtilities performOnMainThread:@selector(orderFrontRegardless)
+                                      on:window
+                              withObject:nil
+                           waitUntilDone:NO];
 
 JNF_COCOA_EXIT(env);
 }
@@ -233,7 +233,7 @@
 
     NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
     NSWindow *relativeTo = (NSWindow *)jlong_to_ptr(relativeToPtr);
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         [window orderWindow:(NSWindowOrderingMode)order relativeTo:[relativeTo windowNumber]];
     }];
 
@@ -267,7 +267,7 @@
         initLevels();
 
         NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
-        [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
+        [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
             [window setLevel: LEVELS[level]];
         }];
     } else {
@@ -290,7 +290,7 @@
 
     NSWindow *parent = (NSWindow *)jlong_to_ptr(parentPtr);
     NSWindow *child = (NSWindow *)jlong_to_ptr(childPtr);
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         [parent addChildWindow:child ordered:order];
     }];
 
@@ -310,10 +310,10 @@
 
     AWTWindow *parent = (AWTWindow *)jlong_to_ptr(parentPtr);
     AWTWindow *child = (AWTWindow *)jlong_to_ptr(childPtr);
-    [JNFRunLoop performOnMainThread:@selector(removeChildWindow:)
-                                 on:parent
-                         withObject:child
-                      waitUntilDone:NO];
+    [ThreadUtilities performOnMainThread:@selector(removeChildWindow:)
+                                      on:parent
+                              withObject:child
+                           waitUntilDone:NO];
 
 JNF_COCOA_EXIT(env);
 }
@@ -331,7 +331,7 @@
 
     AWTWindow *window = (AWTWindow *)jlong_to_ptr(windowPtr);
     NSRect frame = NSMakeRect(x, y, w, h);
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         [window setFrame:frame display:display];
     }];
 
@@ -350,7 +350,7 @@
 JNF_COCOA_ENTER(env);
 
     AWTWindow *window = (AWTWindow *)jlong_to_ptr(windowPtr);
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         [window setAlphaValue:(CGFloat)alpha];
     }];
 
@@ -369,7 +369,7 @@
 JNF_COCOA_ENTER(env);
 
     AWTWindow *window = (AWTWindow *)jlong_to_ptr(windowPtr);
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         [window setOpaque:(BOOL)opaque];
     }];
 
@@ -389,7 +389,7 @@
 
     AWTWindow *window = (AWTWindow *)jlong_to_ptr(windowPtr);
     NSColor *color = (NSColor *)jlong_to_ptr(colorPtr);
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         [window setBackgroundColor:color];
     }];
 
@@ -410,7 +410,7 @@
 JNF_COCOA_ENTER(env);
 
     AWTWindow *window = (AWTWindow *)jlong_to_ptr(windowPtr);
-    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
         const NSScreen *screen = [window screen];
         CFRetain(screen); // GC
         screenPtr = ptr_to_jlong(screen);
@@ -432,10 +432,10 @@
 JNF_COCOA_ENTER(env);
 
     NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
-    [JNFRunLoop performOnMainThread:@selector(miniaturize:)
-                                 on:window
-                         withObject:nil
-                      waitUntilDone:NO];
+    [ThreadUtilities performOnMainThread:@selector(miniaturize:)
+                                      on:window
+                              withObject:nil
+                           waitUntilDone:NO];
 
 JNF_COCOA_EXIT(env);
 }
@@ -452,10 +452,10 @@
 JNF_COCOA_ENTER(env);
 
     NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
-    [JNFRunLoop performOnMainThread:@selector(deminiaturize:)
-                                 on:window
-                         withObject:nil
-                      waitUntilDone:NO];
+    [ThreadUtilities performOnMainThread:@selector(deminiaturize:)
+                                      on:window
+                              withObject:nil
+                           waitUntilDone:NO];
 
 JNF_COCOA_EXIT(env);
 }
@@ -472,10 +472,10 @@
 JNF_COCOA_ENTER(env);
 
     NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
-    [JNFRunLoop performOnMainThread:@selector(zoom:)
-                                 on:window
-                         withObject:nil
-                      waitUntilDone:NO];
+    [ThreadUtilities performOnMainThread:@selector(zoom:)
+                                      on:window
+                              withObject:nil
+                           waitUntilDone:NO];
 
 JNF_COCOA_EXIT(env);
 }
@@ -493,10 +493,10 @@
 
     NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
     NSResponder *responder = (NSResponder *)jlong_to_ptr(responderPtr);
-    [JNFRunLoop performOnMainThread:@selector(makeFirstResponder:)
-                                 on:window
-                         withObject:responder
-                      waitUntilDone:NO];
+    [ThreadUtilities performOnMainThread:@selector(makeFirstResponder:)
+                                      on:window
+                              withObject:responder
+                           waitUntilDone:NO];
 
 JNF_COCOA_EXIT(env);
 }
@@ -514,7 +514,7 @@
 
     NSView *view = (NSView *)jlong_to_ptr(viewPtr);
     NSView *subview = (NSView *)jlong_to_ptr(subviewPtr);
-    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
         [view addSubview:subview];
     }];
 
@@ -533,10 +533,10 @@
 JNF_COCOA_ENTER(env);
 
     NSView *view = (NSView *)jlong_to_ptr(viewPtr);
-    [JNFRunLoop performOnMainThread:@selector(removeFromSuperview)
-                                 on:view
-                         withObject:nil
-                      waitUntilDone:NO];
+    [ThreadUtilities performOnMainThread:@selector(removeFromSuperview)
+                                      on:view
+                              withObject:nil
+                           waitUntilDone:NO];
 
 JNF_COCOA_EXIT(env);
 }
@@ -553,7 +553,7 @@
 JNF_COCOA_ENTER(env);
 
     NSView *view = (NSView *)jlong_to_ptr(viewPtr);
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         [view setFrame:NSMakeRect(x, y, w, h)];
     }];
 
@@ -576,7 +576,7 @@
     __block NSRect rect = NSZeroRect;
 
     NSView *view = (NSView *)jlong_to_ptr(viewPtr);
-    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
         rect = [view frame];
     }];
 
@@ -599,7 +599,7 @@
 JNF_COCOA_ENTER(env);
 
     NSView *view = (NSView *)jlong_to_ptr(viewPtr);
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         NSScreen *screen = [[view window] screen];
         NSDictionary *opts = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:NO], NSFullScreenModeAllScreens, nil];
         [view enterFullScreenMode:screen withOptions:opts];
@@ -620,7 +620,7 @@
 JNF_COCOA_ENTER(env);
 
     NSView *view = (NSView *)jlong_to_ptr(viewPtr);
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         [view exitFullScreenModeWithOptions:nil];
     }];
 
@@ -641,7 +641,7 @@
 JNF_COCOA_ENTER(env);
 
     NSView *view = (NSView *)jlong_to_ptr(viewPtr);
-    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
         windowPtr = ptr_to_jlong([view window]);
     }];
 
@@ -655,14 +655,14 @@
  * Method:    setHidden
  * Signature: (JZ)V
  */
-JNIEXPORT jlong JNICALL
+JNIEXPORT void JNICALL
 Java_sun_lwawt_macosx_CWrapper_00024NSView_setHidden
 (JNIEnv *env, jclass cls, jlong viewPtr, jboolean toHide)
 {    
     JNF_COCOA_ENTER(env);
     
     NSView *view = (NSView *)jlong_to_ptr(viewPtr);
-    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
         [view setHidden:(BOOL)toHide];
     }];
     
@@ -686,7 +686,7 @@
     __block NSRect rect = NSZeroRect;
 
     NSScreen *screen = (NSScreen *)jlong_to_ptr(screenPtr);
-    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
         rect = [screen frame];
     }];
 
@@ -713,7 +713,7 @@
     __block NSRect rect = NSZeroRect;
 
     NSScreen *screen = (NSScreen *)jlong_to_ptr(screenPtr);
-    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
         rect = [screen visibleFrame];
     }];
 
@@ -737,7 +737,7 @@
 
 JNF_COCOA_ENTER(env);
 
-    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
         NSArray *screens = [NSScreen screens];
         for (NSScreen *screen in screens) {
             NSDictionary *screenInfo = [screen deviceDescription];
@@ -768,7 +768,7 @@
 
 JNF_COCOA_ENTER(env);
 
-    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
         clearColorPtr = ptr_to_jlong([NSColor clearColor]);
     }];
 
--- a/jdk/src/macosx/native/sun/awt/JavaComponentAccessibility.m	Fri Jan 18 14:17:11 2013 +0400
+++ b/jdk/src/macosx/native/sun/awt/JavaComponentAccessibility.m	Fri Jan 18 18:17:02 2013 +0400
@@ -1147,7 +1147,6 @@
 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessibility_focusChanged
 (JNIEnv *env, jobject jthis)
 {
-    AWT_ASSERT_NOT_APPKIT_THREAD;
 
 JNF_COCOA_ENTER(env);
     [ThreadUtilities performOnMainThread:@selector(postFocusChanged:) onObject:[JavaComponentAccessibility class] withObject:nil waitUntilDone:NO awtMode:NO];
@@ -1164,7 +1163,6 @@
 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_valueChanged
 (JNIEnv *env, jclass jklass, jlong element)
 {
-    AWT_ASSERT_NOT_APPKIT_THREAD;
 JNF_COCOA_ENTER(env);
     [ThreadUtilities performOnMainThread:@selector(postValueChanged) onObject:(JavaComponentAccessibility *)jlong_to_ptr(element) withObject:nil waitUntilDone:NO awtMode:NO];
 JNF_COCOA_EXIT(env);
@@ -1178,7 +1176,6 @@
 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_selectionChanged
 (JNIEnv *env, jclass jklass, jlong element)
 {
-    AWT_ASSERT_NOT_APPKIT_THREAD;
 JNF_COCOA_ENTER(env);
     [ThreadUtilities performOnMainThread:@selector(postSelectionChanged) onObject:(JavaComponentAccessibility *)jlong_to_ptr(element) withObject:nil waitUntilDone:NO awtMode:NO];
 JNF_COCOA_EXIT(env);
@@ -1193,7 +1190,6 @@
 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_unregisterFromCocoaAXSystem
 (JNIEnv *env, jclass jklass, jlong element)
 {
-    AWT_ASSERT_NOT_APPKIT_THREAD;
 JNF_COCOA_ENTER(env);
     [ThreadUtilities performOnMainThread:@selector(unregisterFromCocoaAXSystem) onObject:(JavaComponentAccessibility *)jlong_to_ptr(element) withObject:nil waitUntilDone:NO awtMode:NO];
 JNF_COCOA_EXIT(env);
--- a/jdk/src/macosx/native/sun/awt/LWCToolkit.m	Fri Jan 18 14:17:11 2013 +0400
+++ b/jdk/src/macosx/native/sun/awt/LWCToolkit.m	Fri Jan 18 18:17:02 2013 +0400
@@ -415,13 +415,9 @@
 
 JNF_COCOA_ENTER(env);
 
-    if ([NSThread isMainThread]) {
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^() {
         active = (jboolean)[NSRunningApplication currentApplication].active;
-    } else {
-        [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^() {
-            active = (jboolean)[NSRunningApplication currentApplication].active;
-        }];
-    }
+    }];
 
 JNF_COCOA_EXIT(env);
 
--- a/jdk/src/macosx/native/sun/awt/awt.m	Fri Jan 18 14:17:11 2013 +0400
+++ b/jdk/src/macosx/native/sun/awt/awt.m	Fri Jan 18 18:17:02 2013 +0400
@@ -315,14 +315,9 @@
     // Don't set the delegate until the NSApplication has been created and
     // its finishLaunching has initialized it.
     //  ApplicationDelegate is the support code for com.apple.eawt.
-    void (^setDelegateBlock)() = ^(){
+    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
         OSXAPP_SetApplicationDelegate([ApplicationDelegate sharedDelegate]);
-    };
-    if (onMainThread) {
-        setDelegateBlock();
-    } else {
-        [JNFRunLoop performOnMainThreadWaiting:YES withBlock:setDelegateBlock];
-    }
+    }];
 }
 
 - (void)starter:(NSArray*)args {
--- a/jdk/src/macosx/native/sun/osxapp/ThreadUtilities.h	Fri Jan 18 14:17:11 2013 +0400
+++ b/jdk/src/macosx/native/sun/osxapp/ThreadUtilities.h	Fri Jan 18 18:17:02 2013 +0400
@@ -98,8 +98,6 @@
     }                                          \
 } while (0)
 
-#define AWT_ASSERT_ANY_THREAD
-
 #endif /* AWT_THREAD_ASSERTS_MESSAGES */
 
 #ifdef AWT_THREAD_ASSERTS_WAIT
@@ -114,15 +112,12 @@
     while (pthread_main_np() != 0) {} \
 } while (0)
 
-#define AWT_ASSERT_ANY_THREAD
-
 #endif /* AWT_THREAD_ASSERTS_WAIT */
 
 #else /* AWT_THREAD_ASSERTS */
 
 #define AWT_ASSERT_APPKIT_THREAD     do {} while (0)
 #define AWT_ASSERT_NOT_APPKIT_THREAD do {} while (0)
-#define AWT_ASSERT_ANY_THREAD
 
 #endif /* AWT_THREAD_ASSERTS */
 // --------------------------------------------------------------------------
@@ -139,7 +134,10 @@
 + (JNIEnv*)getJNIEnvUncached;
 
 + (void)performOnMainThread:(SEL)aSelector onObject:(id)target withObject:(id)arg waitUntilDone:(BOOL)wait awtMode:(BOOL)inAWT;
+
+//Wrappers for the corresponding JNFRunLoop methods with a check for main thread
 + (void)performOnMainThreadWaiting:(BOOL)wait block:(void (^)())block;
++ (void)performOnMainThread:(SEL)aSelector on:(id)target withObject:(id)arg waitUntilDone:(BOOL)wait;
 @end
 
 void OSXAPP_SetJavaVM(JavaVM *vm);
--- a/jdk/src/macosx/native/sun/osxapp/ThreadUtilities.m	Fri Jan 18 14:17:11 2013 +0400
+++ b/jdk/src/macosx/native/sun/osxapp/ThreadUtilities.m	Fri Jan 18 18:17:02 2013 +0400
@@ -37,27 +37,13 @@
 static NSArray *sPerformModes = nil;
 static NSArray *sAWTPerformModes = nil;
 
-static BOOL sCocoaComponentCompatibility = NO;
-static NSTimeInterval sCocoaComponentCompatibilityTimeout = 0.5;
 static BOOL sLoggingEnabled = YES;
 
 #ifdef AWT_THREAD_ASSERTS_ENV_ASSERT
 int sAWTThreadAsserts = 0;
 #endif /* AWT_THREAD_ASSERTS_ENV_ASSERT */
 
-
-// This is for backward compatibility for those people using CocoaComponent
-// Since we've flipped the AWT threading model for Tiger (10.4), all the rules
-// for CocoaComponent are wrong.
-// So for existing CocoaComponent users, we can't be synchronous.
-// Making things totally asynchronous breaks a _lot_, so we try to be
-// synchronous and time out after a little bit.
-#define NOT_READY 0
-#define READY 1
-#define IN_PROGRESS 2
-
 BOOL sInPerformFromJava = NO;
-NSUInteger sPerformCount = 0;
 
 // This class is used so that performSelectorOnMainThread can be
 // controlled a little more easily by us.  It has 2 roles.
@@ -73,8 +59,6 @@
 
 - (id) initWithTarget:(id)target selector:(SEL)selector arg:(id)arg wait:(BOOL)wait;
 - (void) perform;
-- (void) performCompatible;
-- (void) _performCompatible:(NSConditionLock *)resultLock;
 @end
 
 
@@ -113,8 +97,6 @@
         sInPerformFromJava = YES;
     }
 
-    sPerformCount++;
-
     // Actually do the work (cheat to avoid a method call)
     @try {
         objc_msgSend(fTarget, fSelector, fArg);
@@ -128,69 +110,6 @@
         }
     }
 }
-
-- (void) performCompatible {
-    // We check if we are on the AppKit thread because frequently, apps
-    // using CocoaComponent are doing things on the wrong thread!
-    if (pthread_main_np()) {
-        [fTarget performSelector:fSelector withObject:fArg];
-    } else {
-        // Setup the lock
-        NSConditionLock *resultLock =
-            [[NSConditionLock alloc] initWithCondition:NOT_READY];
-
-        // Make sure that if we return early, nothing gets released out
-        // from under us
-        [resultLock retain];
-        [fTarget retain];
-        [fArg retain];
-        [self retain];
-        // Do an asynchronous perform to the main thread.
-        [self performSelectorOnMainThread:@selector(_performCompatible:)
-              withObject:resultLock waitUntilDone:NO modes:sAWTPerformModes];
-
-        // Wait for a little bit for it to finish
-        [resultLock lockWhenCondition:READY beforeDate:[NSDate dateWithTimeIntervalSinceNow:sCocoaComponentCompatibilityTimeout]];
-
-        // If the _performCompatible is actually in progress,
-        // we should let it finish
-        if ([resultLock condition] == IN_PROGRESS) {
-            [resultLock lockWhenCondition:READY];
-        }
-
-        if ([resultLock condition] == NOT_READY && sLoggingEnabled) {
-            NSLog(@"[Java CocoaComponent compatibility mode]: Operation timed out due to possible deadlock: selector '%@' on target '%@' with args '%@'", NSStringFromSelector(fSelector), fTarget, fArg);
-        }
-
-        [resultLock unlock];
-        [resultLock autorelease];
-    }
-}
-
-- (void) _performCompatible:(NSConditionLock *)resultLock {
-    // notify that the perform is in progress!
-    [resultLock lock];
-    [resultLock unlockWithCondition:IN_PROGRESS];
-
-    sPerformCount++;
-
-    // Actually do the work.
-    @try {
-        [fTarget performSelector:fSelector withObject:fArg];
-    } @catch (NSException *e) {
-        NSLog(@"*** CPerformer: ignoring exception '%@' raised during performCompatible of selector '%@' on target '%@' with args '%@'", e, NSStringFromSelector(fSelector), fTarget, fArg);
-    } @finally {
-        // notify done!
-        [resultLock lock];
-        [resultLock unlockWithCondition:READY];
-
-        // Clean up after ourselves
-        [resultLock autorelease];
-        [fTarget autorelease];
-        [fArg autorelease];
-        [self autorelease];
-    }
-}
 @end
 
 
@@ -236,13 +155,8 @@
 // java event thread without deadlocking. See CToolkit.invokeAndWait.
 + (void)performOnMainThread:(SEL)aSelector onObject:(id)target withObject:(id)arg waitUntilDone:(BOOL)wait awtMode:(BOOL)inAWT {
     CPerformer *performer = [[CPerformer alloc] initWithTarget:target selector:aSelector arg:arg wait:wait];
-    if (sCocoaComponentCompatibility && wait && inAWT) {
-        [performer performCompatible];
-        [performer autorelease];
-    } else {
-        [performer performSelectorOnMainThread:@selector(perform) withObject:nil waitUntilDone:wait modes:((inAWT) ? sAWTPerformModes : sPerformModes)]; // AWT_THREADING Safe (cover method)
-        [performer release];
-    }
+    [performer performSelectorOnMainThread:@selector(perform) withObject:nil waitUntilDone:wait modes:((inAWT) ? sAWTPerformModes : sPerformModes)]; // AWT_THREADING Safe (cover method)
+    [performer release];
 }
 
 + (void)performOnMainThreadWaiting:(BOOL)wait block:(void (^)())block {
@@ -253,6 +167,14 @@
     }
 }
 
++ (void)performOnMainThread:(SEL)aSelector on:(id)target withObject:(id)arg waitUntilDone:(BOOL)wait {
+    if ([NSThread isMainThread] && wait == YES) {
+        [target performSelector:aSelector withObject:arg];
+    } else {
+        [JNFRunLoop performOnMainThread:aSelector on:target withObject:arg waitUntilDone:wait];
+    }
+}
+
 @end