8344011: Remove usage of security manager from Class and reflective APIs

Reviewed-by: liach, yzheng, rriggs
This commit is contained in:
Alan Bateman 2024-11-14 07:39:28 +00:00
parent c977ef7b45
commit abacece826
26 changed files with 163 additions and 1251 deletions

View file

@ -39,8 +39,6 @@ import java.lang.reflect.AccessFlag;
import java.lang.reflect.AnnotatedElement;
import java.net.URI;
import java.net.URL;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@ -64,14 +62,12 @@ import jdk.internal.misc.CDS;
import jdk.internal.misc.Unsafe;
import jdk.internal.misc.VM;
import jdk.internal.module.ModuleBootstrap;
import jdk.internal.module.ModuleBootstrap.IllegalNativeAccess;
import jdk.internal.module.ModuleLoaderMap;
import jdk.internal.module.ServicesCatalog;
import jdk.internal.module.Resources;
import jdk.internal.reflect.CallerSensitive;
import jdk.internal.reflect.Reflection;
import jdk.internal.vm.annotation.Stable;
import sun.security.util.SecurityConstants;
/**
* Represents a run-time module, either {@link #isNamed() named} or unnamed.
@ -198,11 +194,6 @@ public final class Module implements AnnotatedElement {
* @return The class loader for this module
*/
public ClassLoader getClassLoader() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION);
}
return loader;
}
@ -1556,7 +1547,6 @@ public final class Module implements AnnotatedElement {
// cached class file with annotations
private volatile Class<?> moduleInfoClass;
@SuppressWarnings("removal")
private Class<?> moduleInfoClass() {
Class<?> clazz = this.moduleInfoClass;
if (clazz != null)
@ -1566,8 +1556,7 @@ public final class Module implements AnnotatedElement {
clazz = this.moduleInfoClass;
if (clazz == null) {
if (isNamed()) {
PrivilegedAction<Class<?>> pa = this::loadModuleInfoClass;
clazz = AccessController.doPrivileged(pa);
clazz = loadModuleInfoClass();
}
if (clazz == null) {
class DummyModuleInfo { }