8037477: Reproducible hang of JAWS and webstart application with JAB 2.0.4
authorpchelko
Mon, 21 Apr 2014 11:00:46 +0400
changeset 24523 d3d9e027b190
parent 24522 3a0bbf9f5e81
child 24524 d6acfe6e6bd8
8037477: Reproducible hang of JAWS and webstart application with JAB 2.0.4 Reviewed-by: anthony, serb
jdk/src/share/classes/javax/accessibility/AccessibleContext.java
jdk/src/share/classes/sun/awt/AWTAccessor.java
--- a/jdk/src/share/classes/javax/accessibility/AccessibleContext.java	Fri Apr 18 09:56:34 2014 -0700
+++ b/jdk/src/share/classes/javax/accessibility/AccessibleContext.java	Mon Apr 21 11:00:46 2014 +0400
@@ -25,6 +25,9 @@
 
 package javax.accessibility;
 
+import sun.awt.AWTAccessor;
+import sun.awt.AppContext;
+
 import java.util.Locale;
 import java.beans.PropertyChangeListener;
 import java.beans.PropertyChangeSupport;
@@ -79,6 +82,26 @@
  */
 public abstract class AccessibleContext {
 
+    /**
+     * The AppContext that should be used to dispatch events for this
+     * AccessibleContext
+     */
+    private volatile AppContext targetAppContext;
+
+    static {
+        AWTAccessor.setAccessibleContextAccessor(new AWTAccessor.AccessibleContextAccessor() {
+            @Override
+            public void setAppContext(AccessibleContext accessibleContext, AppContext appContext) {
+                accessibleContext.targetAppContext = appContext;
+            }
+
+            @Override
+            public AppContext getAppContext(AccessibleContext accessibleContext) {
+                return accessibleContext.targetAppContext;
+            }
+        });
+    }
+
    /**
     * Constant used to determine when the accessibleName property has
     * changed.  The old value in the PropertyChangeEvent will be the old
--- a/jdk/src/share/classes/sun/awt/AWTAccessor.java	Fri Apr 18 09:56:34 2014 -0700
+++ b/jdk/src/share/classes/sun/awt/AWTAccessor.java	Mon Apr 21 11:00:46 2014 +0400
@@ -27,6 +27,7 @@
 
 import sun.misc.Unsafe;
 
+import javax.accessibility.AccessibleContext;
 import java.awt.*;
 import java.awt.KeyboardFocusManager;
 import java.awt.DefaultKeyboardFocusManager;
@@ -762,6 +763,14 @@
     }
 
     /*
+     * An accessor object for the AccessibleContext class
+     */
+    public interface AccessibleContextAccessor {
+        void setAppContext(AccessibleContext accessibleContext, AppContext appContext);
+        AppContext getAppContext(AccessibleContext accessibleContext);
+    }
+
+    /*
      * Accessor instances are initialized in the static initializers of
      * corresponding AWT classes by using setters defined below.
      */
@@ -791,6 +800,7 @@
     private static ToolkitAccessor toolkitAccessor;
     private static InvocationEventAccessor invocationEventAccessor;
     private static SystemColorAccessor systemColorAccessor;
+    private static AccessibleContextAccessor accessibleContextAccessor;
 
     /*
      * Set an accessor object for the java.awt.Component class.
@@ -1234,4 +1244,21 @@
      public static void setSystemColorAccessor(SystemColorAccessor systemColorAccessor) {
          AWTAccessor.systemColorAccessor = systemColorAccessor;
      }
+
+    /*
+     * Get the accessor object for the javax.accessibility.AccessibleContext class.
+     */
+    public static AccessibleContextAccessor getAccessibleContextAccessor() {
+        if (accessibleContextAccessor == null) {
+            unsafe.ensureClassInitialized(AccessibleContext.class);
+        }
+        return accessibleContextAccessor;
+    }
+
+   /*
+    * Set the accessor object for the javax.accessibility.AccessibleContext class.
+    */
+    public static void setAccessibleContextAccessor(AccessibleContextAccessor accessor) {
+        AWTAccessor.accessibleContextAccessor = accessor;
+    }
 }