8012243: about 30% regression on specjvm2008.serial on 7u25 comparing 7u21
Reviewed-by: alanb, skoivu, smarks, mchung
--- 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;
}