8012243: about 30% regression on specjvm2008.serial on 7u25 comparing 7u21
authordfuchs
Thu, 02 May 2013 10:46:09 +0200
changeset 18260 7ef05ae0bd19
parent 18259 ac87cc8d81aa
child 18261 3d81094a9d10
8012243: about 30% regression on specjvm2008.serial on 7u25 comparing 7u21 Reviewed-by: alanb, skoivu, smarks, mchung
jdk/src/share/classes/java/io/ObjectStreamClass.java
jdk/src/share/classes/java/io/ObjectStreamField.java
--- a/jdk/src/share/classes/java/io/ObjectStreamClass.java	Tue Apr 30 13:55:48 2013 +0400
+++ b/jdk/src/share/classes/java/io/ObjectStreamClass.java	Thu May 02 10:46:09 2013 +0200
@@ -266,9 +266,11 @@
         if (cl == null) {
             return null;
         }
-        Class<?> caller = Reflection.getCallerClass();
-        if (ReflectUtil.needsPackageAccessCheck(caller.getClassLoader(), cl.getClassLoader())) {
-            ReflectUtil.checkPackageAccess(cl);
+        if (System.getSecurityManager() != null) {
+            Class<?> caller = Reflection.getCallerClass();
+            if (ReflectUtil.needsPackageAccessCheck(caller.getClassLoader(), cl.getClassLoader())) {
+                ReflectUtil.checkPackageAccess(cl);
+            }
         }
         return cl;
     }
--- a/jdk/src/share/classes/java/io/ObjectStreamField.java	Tue Apr 30 13:55:48 2013 +0400
+++ b/jdk/src/share/classes/java/io/ObjectStreamField.java	Thu May 02 10:46:09 2013 +0200
@@ -162,9 +162,11 @@
      */
     @CallerSensitive
     public Class<?> getType() {
-        Class<?> caller = Reflection.getCallerClass();
-        if (ReflectUtil.needsPackageAccessCheck(caller.getClassLoader(), type.getClassLoader())) {
-            ReflectUtil.checkPackageAccess(type);
+        if (System.getSecurityManager() != null) {
+            Class<?> caller = Reflection.getCallerClass();
+            if (ReflectUtil.needsPackageAccessCheck(caller.getClassLoader(), type.getClassLoader())) {
+                ReflectUtil.checkPackageAccess(type);
+            }
         }
         return type;
     }