6736293: OpenType checks can be bypassed through finalizer resurrection
authoremcmanus
Thu, 07 May 2009 10:44:45 +0200
changeset 3446 4a07252d2e92
parent 3445 39d00a6cac5e
child 3447 7d593a130994
child 3454 0d34cbec5989
6736293: OpenType checks can be bypassed through finalizer resurrection Reviewed-by: hawtin
jdk/src/share/classes/java/awt/Window.java
jdk/src/share/classes/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java
jdk/src/share/classes/javax/management/openmbean/OpenType.java
--- a/jdk/src/share/classes/java/awt/Window.java	Wed May 06 15:17:22 2009 +0400
+++ b/jdk/src/share/classes/java/awt/Window.java	Thu May 07 10:44:45 2009 +0200
@@ -3629,6 +3629,8 @@
                 y + h + 2);
 
         // Now make sure the warning window is visible on the screen
+        GraphicsConfiguration graphicsConfig =
+            getGraphicsConfiguration_NoClientCode();
         Rectangle screenBounds = graphicsConfig.getBounds();
         Insets screenInsets =
             Toolkit.getDefaultToolkit().getScreenInsets(graphicsConfig);
--- a/jdk/src/share/classes/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java	Wed May 06 15:17:22 2009 +0400
+++ b/jdk/src/share/classes/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java	Thu May 07 10:44:45 2009 +0200
@@ -690,7 +690,7 @@
     private static <T> T convertFromString(String s, OpenType<T> openType) {
         Class<T> c;
         try {
-            c = cast(Class.forName(openType.getClassName()));
+            c = cast(Class.forName(openType.safeGetClassName()));
         } catch (ClassNotFoundException e) {
             throw new NoClassDefFoundError(e.toString());  // can't happen
         }
@@ -711,7 +711,7 @@
             } catch (Exception e) {
                 final String msg =
                     "Could not convert \"" + s + "\" using method: " + valueOf;
-                throw new IllegalArgumentException(msg);
+                throw new IllegalArgumentException(msg, e);
             }
         }
 
@@ -728,7 +728,7 @@
             } catch (Exception e) {
                 final String msg =
                     "Could not convert \"" + s + "\" using constructor: " + con;
-                throw new IllegalArgumentException(msg);
+                throw new IllegalArgumentException(msg, e);
             }
         }
 
@@ -757,7 +757,7 @@
             stringArrayClass =
                 Class.forName(squareBrackets + "Ljava.lang.String;");
             targetArrayClass =
-                Class.forName(squareBrackets + "L" + baseType.getClassName() +
+                Class.forName(squareBrackets + "L" + baseType.safeGetClassName() +
                               ";");
         } catch (ClassNotFoundException e) {
             throw new NoClassDefFoundError(e.toString());  // can't happen
--- a/jdk/src/share/classes/javax/management/openmbean/OpenType.java	Wed May 06 15:17:22 2009 +0400
+++ b/jdk/src/share/classes/javax/management/openmbean/OpenType.java	Thu May 07 10:44:45 2009 +0200
@@ -304,7 +304,12 @@
      * @return the class name.
      */
     public String getClassName() {
+        return className;
+    }
 
+    // A version of getClassName() that can only be called from within this
+    // package and that cannot be overridden.
+    String safeGetClassName() {
         return className;
     }