changeset 6141:093a1890be06

Merge
author coffeys
date Mon, 25 Feb 2013 16:24:49 +0000
parents a0853a216bd3 (current diff) 4910d7a21607 (diff)
children 05c784caa6d9
files
diffstat 2 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java	Mon Feb 25 16:17:37 2013 +0000
+++ b/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java	Mon Feb 25 16:24:49 2013 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -213,7 +213,6 @@
 
         Object moi;
 
-
         // ------------------------------
         // ------------------------------
         Constructor<?> cons = findConstructor(theClass, null);
@@ -224,6 +223,7 @@
         // Instantiate the new object
         try {
             ReflectUtil.checkPackageAccess(theClass);
+            ReflectUtil.ensureClassAccess(theClass);
             moi= cons.newInstance();
         } catch (InvocationTargetException e) {
             // Wrap the exception.
@@ -270,7 +270,6 @@
         checkMBeanPermission(theClass, null, null, "instantiate");
 
         // Instantiate the new object
-
         // ------------------------------
         // ------------------------------
         final Class<?>[] tab;
@@ -300,6 +299,7 @@
         }
         try {
             ReflectUtil.checkPackageAccess(theClass);
+            ReflectUtil.ensureClassAccess(theClass);
             moi = cons.newInstance(params);
         }
         catch (NoSuchMethodError error) {
--- a/src/share/classes/sun/reflect/misc/ReflectUtil.java	Mon Feb 25 16:17:37 2013 +0000
+++ b/src/share/classes/sun/reflect/misc/ReflectUtil.java	Mon Feb 25 16:24:49 2013 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2013 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -46,6 +46,14 @@
         return cls.newInstance();
     }
 
+    public static void ensureClassAccess(Class clazz)
+           throws IllegalAccessException
+    {
+        int mod = clazz.getModifiers();
+        if ( ! Modifier.isPublic(mod) ){
+            throw new IllegalAccessException("Class is not public and can't be instantiated");
+        }
+    }
     /*
      * Reflection.ensureMemberAccess is overly-restrictive
      * due to a bug. We awkwardly work around it for now.