JDK-7002856 : Provide an accessor for Container.validateUnconditionally()
Type:Bug
Component:client-libs
Sub-Component:java.awt
Affected Version:7
Priority:P2
Status:Closed
Resolution:Fixed
OS:generic
CPU:generic
Submitted:2010-11-25
Updated:2011-05-18
Resolved:2011-05-18
The Version table provides details related to the release that this issue/RFE will be addressed.
Unresolved : Release in which this issue/RFE will be addressed. Resolved: Release in which this issue/RFE has been resolved. Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.
We need to make the Container.validateUnconditionally() method accessible thru the sun.awt.AWTAccessor machinery in order for plugin to be able to call the method on the embedded frame sometime after Applet.init() is called.
Comments
EVALUATION
sun.awt.AWTAccessor.getContainerAccessor().validateUnconditionally(container);
should be invoked, where the 'container' is the container to be validated (e.g. an embedded frame of an applet, or the (J)Applet panel). Note that due to its unconditionality, even if the 'container' itself is currently valid, its descendants will nevertheless be validated to ensure the whole component hierarchy is valid. This is different from a simple call to
container.validate();
since the latter returns immediately if the 'container' is valid.
26-11-2010
SUGGESTED FIX
--- old/src/share/classes/java/awt/Container.java 2010-11-26 15:05:54.000000000 +0300
+++ new/src/share/classes/java/awt/Container.java 2010-11-26 15:05:53.000000000 +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();
+ }
+ });
}
/**
--- old/src/share/classes/sun/awt/AWTAccessor.java 2010-11-26 15:05:55.000000000 +0300
+++ new/src/share/classes/sun/awt/AWTAccessor.java 2010-11-26 15:05:55.000000000 +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 {
@@ -440,53 +450,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;
/*
@@ -497,7 +473,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) {
@@ -508,6 +484,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) {