mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8266459: Implement JEP 411: Deprecate the Security Manager for Removal
Co-authored-by: Sean Mullan <mullan@openjdk.org> Co-authored-by: Lance Andersen <lancea@openjdk.org> Co-authored-by: Weijun Wang <weijun@openjdk.org> Reviewed-by: erikj, darcy, chegar, naoto, joehw, alanb, mchung, kcr, prr, lancea
This commit is contained in:
parent
19450b9951
commit
6765f90250
826 changed files with 2734 additions and 757 deletions
|
@ -82,6 +82,7 @@ public class AccessibleObject implements AnnotatedElement {
|
|||
}
|
||||
|
||||
static void checkPermission() {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
// SecurityConstants.ACCESS_PERMISSION is used to check
|
||||
|
@ -483,6 +484,7 @@ public class AccessibleObject implements AnnotatedElement {
|
|||
// Reflection factory used by subclasses for creating field,
|
||||
// method, and constructor accessors. Note that this is called
|
||||
// very early in the bootstrapping process.
|
||||
@SuppressWarnings("removal")
|
||||
static final ReflectionFactory reflectionFactory =
|
||||
AccessController.doPrivileged(
|
||||
new ReflectionFactory.GetReflectionFactoryAction());
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2021, 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
|
||||
|
@ -390,6 +390,7 @@ public class Proxy implements java.io.Serializable {
|
|||
Class<?>... interfaces)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
@SuppressWarnings("removal")
|
||||
Class<?> caller = System.getSecurityManager() == null
|
||||
? null
|
||||
: Reflection.getCallerClass();
|
||||
|
@ -463,6 +464,7 @@ public class Proxy implements java.io.Serializable {
|
|||
ClassLoader loader,
|
||||
Class<?> ... interfaces)
|
||||
{
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
ClassLoader ccl = caller.getClassLoader();
|
||||
|
@ -663,6 +665,7 @@ public class Proxy implements java.io.Serializable {
|
|||
* Must call the checkProxyAccess method to perform permission checks
|
||||
* before calling this.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
Constructor<?> build() {
|
||||
Class<?> proxyClass = defineProxyClass(module, interfaces);
|
||||
assert !module.isNamed() || module.isOpen(proxyClass.getPackageName(), Proxy.class.getModule());
|
||||
|
@ -1018,6 +1021,7 @@ public class Proxy implements java.io.Serializable {
|
|||
InvocationHandler h) {
|
||||
Objects.requireNonNull(h);
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
final Class<?> caller = System.getSecurityManager() == null
|
||||
? null
|
||||
: Reflection.getCallerClass();
|
||||
|
@ -1055,6 +1059,7 @@ public class Proxy implements java.io.Serializable {
|
|||
}
|
||||
|
||||
private static void checkNewProxyPermission(Class<?> caller, Class<?> proxyClass) {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
if (ReflectUtil.isNonPublicProxyClass(proxyClass)) {
|
||||
|
@ -1076,6 +1081,7 @@ public class Proxy implements java.io.Serializable {
|
|||
/**
|
||||
* Returns the class loader for the given module.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
private static ClassLoader getLoader(Module m) {
|
||||
PrivilegedAction<ClassLoader> pa = m::getClassLoader;
|
||||
return AccessController.doPrivileged(pa);
|
||||
|
@ -1113,6 +1119,7 @@ public class Proxy implements java.io.Serializable {
|
|||
* s.checkPackageAccess()} denies access to the invocation
|
||||
* handler's class.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
@CallerSensitive
|
||||
public static InvocationHandler getInvocationHandler(Object proxy)
|
||||
throws IllegalArgumentException
|
||||
|
@ -1286,6 +1293,7 @@ public class Proxy implements java.io.Serializable {
|
|||
*
|
||||
* @return a lookup for proxy class of this proxy instance
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
private static MethodHandles.Lookup proxyClassLookup(MethodHandles.Lookup caller, Class<?> proxyClass) {
|
||||
return AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2021, 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
|
||||
|
@ -92,6 +92,7 @@ final class ProxyGenerator extends ClassWriter {
|
|||
/**
|
||||
* debugging flag for saving generated class files
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
private static final boolean saveGeneratedFiles =
|
||||
java.security.AccessController.doPrivileged(
|
||||
new GetBooleanAction(
|
||||
|
@ -168,6 +169,7 @@ final class ProxyGenerator extends ClassWriter {
|
|||
* @param interfaces proxy interfaces
|
||||
* @param accessFlags access flags of the proxy class
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
static byte[] generateProxyClass(ClassLoader loader,
|
||||
final String name,
|
||||
List<Class<?>> interfaces,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue