8058870: Mac: JFXPanel deadlocks in jnlp mode
authorant
Wed, 24 Sep 2014 15:36:11 +0400
changeset 27055 57d7b3b1463b
parent 27054 fd70c32a67ab
child 27056 edb2e3793346
8058870: Mac: JFXPanel deadlocks in jnlp mode Reviewed-by: serb, alexsch
jdk/src/java.desktop/share/classes/javax/swing/JComponent.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java	Wed Sep 24 15:23:19 2014 +0400
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java	Wed Sep 24 15:36:11 2014 +0400
@@ -56,6 +56,7 @@
 import java.io.IOException;
 import java.io.ObjectInputValidation;
 import java.io.InvalidObjectException;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 import javax.swing.border.*;
 import javax.swing.event.*;
@@ -354,7 +355,8 @@
     private static final int AUTOSCROLLS_SET                          = 25;
     private static final int FOCUS_TRAVERSAL_KEYS_FORWARD_SET         = 26;
     private static final int FOCUS_TRAVERSAL_KEYS_BACKWARD_SET        = 27;
-    private static final int REVALIDATE_RUNNABLE_SCHEDULED            = 28;
+
+    private transient AtomicBoolean revalidateRunnableScheduled = new AtomicBoolean(false);
 
     /**
      * Temporary rectangles.
@@ -4901,16 +4903,11 @@
             // To avoid a flood of Runnables when constructing GUIs off
             // the EDT, a flag is maintained as to whether or not
             // a Runnable has been scheduled.
-            synchronized(this) {
-                if (getFlag(REVALIDATE_RUNNABLE_SCHEDULED)) {
-                    return;
-                }
-                setFlag(REVALIDATE_RUNNABLE_SCHEDULED, true);
+            if (revalidateRunnableScheduled.getAndSet(true)) {
+                return;
             }
             SunToolkit.executeOnEventHandlerThread(this, () -> {
-                synchronized(JComponent.this) {
-                    setFlag(REVALIDATE_RUNNABLE_SCHEDULED, false);
-                }
+                revalidateRunnableScheduled.set(false);
                 revalidate();
             });
         }
@@ -5567,6 +5564,7 @@
             ToolTipManager.sharedInstance().registerComponent(this);
         }
         setWriteObjCounter(this, (byte)0);
+        revalidateRunnableScheduled = new AtomicBoolean(false);
     }