changeset 1499:a53a57a3260c

6736293: OpenType checks can be bypassed through finalizer resurrection Reviewed-by: hawtin
author emcmanus
date Thu, 07 May 2009 10:44:45 +0200
parents 4b498e41c1c2
children 7b50813648d8 ae62878e6eef
files src/share/classes/java/awt/Window.java src/share/classes/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java src/share/classes/javax/management/openmbean/OpenType.java
diffstat 3 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/awt/Window.java	Wed May 06 15:17:22 2009 +0400
+++ b/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/src/share/classes/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java	Wed May 06 15:17:22 2009 +0400
+++ b/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/src/share/classes/javax/management/openmbean/OpenType.java	Wed May 06 15:17:22 2009 +0400
+++ b/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;
     }