8202419: Avoid creating Permission constants early
Reviewed-by: alanb, mullan
This commit is contained in:
parent
f7afa8ff53
commit
0f478d2cfd
@ -425,7 +425,8 @@ class Thread implements Runnable {
|
|||||||
*/
|
*/
|
||||||
if (security != null) {
|
if (security != null) {
|
||||||
if (isCCLOverridden(getClass())) {
|
if (isCCLOverridden(getClass())) {
|
||||||
security.checkPermission(SUBCLASS_IMPLEMENTATION_PERMISSION);
|
security.checkPermission(
|
||||||
|
SecurityConstants.SUBCLASS_IMPLEMENTATION_PERMISSION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1703,10 +1704,6 @@ class Thread implements Runnable {
|
|||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static final RuntimePermission SUBCLASS_IMPLEMENTATION_PERMISSION =
|
|
||||||
new RuntimePermission("enableContextClassLoaderOverride");
|
|
||||||
|
|
||||||
/** cache of subclass security audit results */
|
/** cache of subclass security audit results */
|
||||||
/* Replace with ConcurrentReferenceHashMap when/if it appears in a future
|
/* Replace with ConcurrentReferenceHashMap when/if it appears in a future
|
||||||
* release */
|
* release */
|
||||||
|
@ -35,6 +35,7 @@ import jdk.internal.reflect.CallerSensitive;
|
|||||||
import jdk.internal.reflect.Reflection;
|
import jdk.internal.reflect.Reflection;
|
||||||
import jdk.internal.reflect.ReflectionFactory;
|
import jdk.internal.reflect.ReflectionFactory;
|
||||||
import sun.security.action.GetPropertyAction;
|
import sun.security.action.GetPropertyAction;
|
||||||
|
import sun.security.util.SecurityConstants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@code AccessibleObject} class is the base class for {@code Field},
|
* The {@code AccessibleObject} class is the base class for {@code Field},
|
||||||
@ -73,17 +74,14 @@ import sun.security.action.GetPropertyAction;
|
|||||||
*/
|
*/
|
||||||
public class AccessibleObject implements AnnotatedElement {
|
public class AccessibleObject implements AnnotatedElement {
|
||||||
|
|
||||||
/**
|
|
||||||
* The Permission object that is used to check whether a client
|
|
||||||
* has sufficient privilege to defeat Java language access
|
|
||||||
* control checks.
|
|
||||||
*/
|
|
||||||
private static final java.security.Permission ACCESS_PERMISSION =
|
|
||||||
new ReflectPermission("suppressAccessChecks");
|
|
||||||
|
|
||||||
static void checkPermission() {
|
static void checkPermission() {
|
||||||
SecurityManager sm = System.getSecurityManager();
|
SecurityManager sm = System.getSecurityManager();
|
||||||
if (sm != null) sm.checkPermission(ACCESS_PERMISSION);
|
if (sm != null) {
|
||||||
|
// SecurityConstants.ACCESS_PERMISSION is used to check
|
||||||
|
// whether a client has sufficient privilege to defeat Java
|
||||||
|
// language access control checks.
|
||||||
|
sm.checkPermission(SecurityConstants.ACCESS_PERMISSION);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,6 +47,7 @@ import java.util.Properties;
|
|||||||
import jdk.internal.misc.VM;
|
import jdk.internal.misc.VM;
|
||||||
import sun.reflect.misc.ReflectUtil;
|
import sun.reflect.misc.ReflectUtil;
|
||||||
import sun.security.action.GetPropertyAction;
|
import sun.security.action.GetPropertyAction;
|
||||||
|
import sun.security.util.SecurityConstants;
|
||||||
|
|
||||||
/** <P> The master factory for all reflective objects, both those in
|
/** <P> The master factory for all reflective objects, both those in
|
||||||
java.lang.reflect (Fields, Methods, Constructors) as well as their
|
java.lang.reflect (Fields, Methods, Constructors) as well as their
|
||||||
@ -63,8 +64,6 @@ import sun.security.action.GetPropertyAction;
|
|||||||
public class ReflectionFactory {
|
public class ReflectionFactory {
|
||||||
|
|
||||||
private static boolean initted = false;
|
private static boolean initted = false;
|
||||||
private static final Permission reflectionFactoryAccessPerm
|
|
||||||
= new RuntimePermission("reflectionFactoryAccess");
|
|
||||||
private static final ReflectionFactory soleInstance = new ReflectionFactory();
|
private static final ReflectionFactory soleInstance = new ReflectionFactory();
|
||||||
// Provides access to package-private mechanisms in java.lang.reflect
|
// Provides access to package-private mechanisms in java.lang.reflect
|
||||||
private static volatile LangReflectAccess langReflectAccess;
|
private static volatile LangReflectAccess langReflectAccess;
|
||||||
@ -129,8 +128,8 @@ public class ReflectionFactory {
|
|||||||
public static ReflectionFactory getReflectionFactory() {
|
public static ReflectionFactory getReflectionFactory() {
|
||||||
SecurityManager security = System.getSecurityManager();
|
SecurityManager security = System.getSecurityManager();
|
||||||
if (security != null) {
|
if (security != null) {
|
||||||
// TO DO: security.checkReflectionFactoryAccess();
|
security.checkPermission(
|
||||||
security.checkPermission(reflectionFactoryAccessPerm);
|
SecurityConstants.REFLECTION_FACTORY_ACCESS_PERMISSION);
|
||||||
}
|
}
|
||||||
return soleInstance;
|
return soleInstance;
|
||||||
}
|
}
|
||||||
|
@ -25,12 +25,10 @@
|
|||||||
|
|
||||||
package sun.security.util;
|
package sun.security.util;
|
||||||
|
|
||||||
|
import java.lang.reflect.ReflectPermission;
|
||||||
import java.net.SocketPermission;
|
import java.net.SocketPermission;
|
||||||
import java.net.NetPermission;
|
import java.net.NetPermission;
|
||||||
import java.security.AccessController;
|
|
||||||
import java.security.PrivilegedAction;
|
|
||||||
import java.security.Permission;
|
import java.security.Permission;
|
||||||
import java.security.BasicPermission;
|
|
||||||
import java.security.SecurityPermission;
|
import java.security.SecurityPermission;
|
||||||
import java.security.AllPermission;
|
import java.security.AllPermission;
|
||||||
import sun.security.action.GetPropertyAction;
|
import sun.security.action.GetPropertyAction;
|
||||||
@ -131,6 +129,10 @@ public final class SecurityConstants {
|
|||||||
public static final RuntimePermission GET_STACK_TRACE_PERMISSION =
|
public static final RuntimePermission GET_STACK_TRACE_PERMISSION =
|
||||||
new RuntimePermission("getStackTrace");
|
new RuntimePermission("getStackTrace");
|
||||||
|
|
||||||
|
// java.lang.Thread
|
||||||
|
public static final RuntimePermission SUBCLASS_IMPLEMENTATION_PERMISSION =
|
||||||
|
new RuntimePermission("enableContextClassLoaderOverride");
|
||||||
|
|
||||||
// java.security.AccessControlContext
|
// java.security.AccessControlContext
|
||||||
public static final SecurityPermission CREATE_ACC_PERMISSION =
|
public static final SecurityPermission CREATE_ACC_PERMISSION =
|
||||||
new SecurityPermission("createAccessControlContext");
|
new SecurityPermission("createAccessControlContext");
|
||||||
@ -149,4 +151,13 @@ public final class SecurityConstants {
|
|||||||
|
|
||||||
public static final String PROVIDER_VER =
|
public static final String PROVIDER_VER =
|
||||||
GetPropertyAction.privilegedGetProperty("java.specification.version");
|
GetPropertyAction.privilegedGetProperty("java.specification.version");
|
||||||
|
|
||||||
|
// java.lang.reflect.AccessibleObject
|
||||||
|
public static final ReflectPermission ACCESS_PERMISSION =
|
||||||
|
new ReflectPermission("suppressAccessChecks");
|
||||||
|
|
||||||
|
// sun.reflect.ReflectionFactory
|
||||||
|
public static final RuntimePermission REFLECTION_FACTORY_ACCESS_PERMISSION =
|
||||||
|
new RuntimePermission("reflectionFactoryAccess");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user