7002856: Provide an accessor for Container.validateUnconditionally()
authoranthony
Fri, 26 Nov 2010 15:41:16 +0300
changeset 7241 ed85b6040a98
parent 7240 2edee4a70f4f
child 7242 6e0aa78a24f6
7002856: Provide an accessor for Container.validateUnconditionally() Summary: Introduce sun.awt.AWTAccessor.getContainerAccessor().validateUnconditionally() Reviewed-by: art
jdk/src/share/classes/java/awt/Container.java
jdk/src/share/classes/sun/awt/AWTAccessor.java
--- a/jdk/src/share/classes/java/awt/Container.java	Fri Nov 26 15:07:53 2010 +0300
+++ b/jdk/src/share/classes/java/awt/Container.java	Fri Nov 26 15:41:16 2010 +0300
@@ -51,6 +51,7 @@
 import sun.util.logging.PlatformLogger;
 
 import sun.awt.AppContext;
+import sun.awt.AWTAccessor;
 import sun.awt.CausedFocusEvent;
 import sun.awt.PeerEvent;
 import sun.awt.SunToolkit;
@@ -247,6 +248,13 @@
         if (!GraphicsEnvironment.isHeadless()) {
             initIDs();
         }
+
+        AWTAccessor.setContainerAccessor(new AWTAccessor.ContainerAccessor() {
+            @Override
+            public void validateUnconditionally(Container cont) {
+                cont.validateUnconditionally();
+            }
+        });
     }
 
     /**
--- a/jdk/src/share/classes/sun/awt/AWTAccessor.java	Fri Nov 26 15:07:53 2010 +0300
+++ b/jdk/src/share/classes/sun/awt/AWTAccessor.java	Fri Nov 26 15:41:16 2010 +0300
@@ -224,6 +224,16 @@
     }
 
     /*
+     * An interface of accessor for the java.awt.Container class.
+     */
+    public interface ContainerAccessor {
+        /**
+         * Validates the container unconditionally.
+         */
+        void validateUnconditionally(Container cont);
+    }
+
+    /*
      * An interface of accessor for java.awt.Window class.
      */
     public interface WindowAccessor {
@@ -444,53 +454,19 @@
     }
 
     /*
-     * The java.awt.Component class accessor object.
+     * Accessor instances are initialized in the static initializers of
+     * corresponding AWT classes by using setters defined below.
      */
     private static ComponentAccessor componentAccessor;
-
-    /*
-     * The java.awt.Window class accessor object.
-     */
+    private static ContainerAccessor containerAccessor;
     private static WindowAccessor windowAccessor;
-
-    /*
-     * The java.awt.AWTEvent class accessor object.
-     */
     private static AWTEventAccessor awtEventAccessor;
-
-    /*
-     * The java.awt.event.InputEvent class accessor object.
-     */
     private static InputEventAccessor inputEventAccessor;
-
-    /*
-     * The java.awt.Frame class accessor object.
-     */
     private static FrameAccessor frameAccessor;
-
-    /*
-     * The java.awt.KeyboardFocusManager class accessor object.
-     */
     private static KeyboardFocusManagerAccessor kfmAccessor;
-
-    /*
-     * The java.awt.MenuComponent class accessor object.
-     */
     private static MenuComponentAccessor menuComponentAccessor;
-
-    /*
-     * The java.awt.EventQueue class accessor object.
-     */
     private static EventQueueAccessor eventQueueAccessor;
-
-    /*
-     * The java.awt.PopupMenu class accessor object.
-     */
     private static PopupMenuAccessor popupMenuAccessor;
-
-    /*
-     * The java.awt.FileDialog class accessor object.
-     */
     private static FileDialogAccessor fileDialogAccessor;
 
     /*
@@ -501,7 +477,7 @@
     }
 
     /*
-     * Retrieve the accessor object for the java.awt.Window class.
+     * Retrieve the accessor object for the java.awt.Component class.
      */
     public static ComponentAccessor getComponentAccessor() {
         if (componentAccessor == null) {
@@ -512,6 +488,24 @@
     }
 
     /*
+     * Set an accessor object for the java.awt.Container class.
+     */
+    public static void setContainerAccessor(ContainerAccessor ca) {
+        containerAccessor = ca;
+    }
+
+    /*
+     * Retrieve the accessor object for the java.awt.Container class.
+     */
+    public static ContainerAccessor getContainerAccessor() {
+        if (containerAccessor == null) {
+            unsafe.ensureClassInitialized(Container.class);
+        }
+
+        return containerAccessor;
+    }
+
+    /*
      * Set an accessor object for the java.awt.Window class.
      */
     public static void setWindowAccessor(WindowAccessor wa) {