src/macosx/classes/sun/lwawt/macosx/CToolkitThreadBlockedHandler.java

Print this page

        

@@ -26,11 +26,14 @@
 package sun.lwawt.macosx;
 
 import sun.awt.datatransfer.ToolkitThreadBlockedHandler;
 
 final class CToolkitThreadBlockedHandler implements ToolkitThreadBlockedHandler {
-    private final LWCToolkit toolkit = (LWCToolkit)java.awt.Toolkit.getDefaultToolkit();
+    private final LWCToolkit toolkit =
+            java.awt.Toolkit.getDefaultToolkit() instanceof LWCToolkit
+                    ? (LWCToolkit)java.awt.Toolkit.getDefaultToolkit()
+                    : null;
 
     public void lock() {
     }
 
     public void unlock() {

@@ -42,11 +45,13 @@
 
     public void enter() {
         // Despite the naming of this method, on MacOS only one
         // event is read and dispatched before this method returns.
         // This call is non-blocking and does not wait for an event
+        if (toolkit != null) {
         toolkit.startNativeNestedEventLoop();
     }
+    }
 
     public void exit() {
     }
 }