mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +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
|
@ -407,6 +407,7 @@ public final class ServiceLoader<S>
|
|||
private final ClassLoader loader;
|
||||
|
||||
// The access control context taken when the ServiceLoader is created
|
||||
@SuppressWarnings("removal")
|
||||
private final AccessControlContext acc;
|
||||
|
||||
// The lazy-lookup iterator for iterator operations
|
||||
|
@ -474,6 +475,7 @@ public final class ServiceLoader<S>
|
|||
* If {@code svc} is not accessible to {@code caller} or the caller
|
||||
* module does not use the service type.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
private ServiceLoader(Class<?> caller, ModuleLayer layer, Class<S> svc) {
|
||||
Objects.requireNonNull(caller);
|
||||
Objects.requireNonNull(layer);
|
||||
|
@ -497,6 +499,7 @@ public final class ServiceLoader<S>
|
|||
* If {@code svc} is not accessible to {@code caller} or the caller
|
||||
* module does not use the service type.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
private ServiceLoader(Class<?> caller, Class<S> svc, ClassLoader cl) {
|
||||
Objects.requireNonNull(svc);
|
||||
|
||||
|
@ -539,6 +542,7 @@ public final class ServiceLoader<S>
|
|||
* @throws ServiceConfigurationError
|
||||
* If the caller module does not use the service type.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
private ServiceLoader(Module callerModule, Class<S> svc, ClassLoader cl) {
|
||||
if (!callerModule.canUse(svc)) {
|
||||
fail(svc, callerModule + " does not declare `uses`");
|
||||
|
@ -610,6 +614,7 @@ public final class ServiceLoader<S>
|
|||
* provider method or there is more than one public static
|
||||
* provider method
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
private Method findStaticProviderMethod(Class<?> clazz) {
|
||||
List<Method> methods = null;
|
||||
try {
|
||||
|
@ -652,6 +657,7 @@ public final class ServiceLoader<S>
|
|||
* @throws ServiceConfigurationError if the class does not have
|
||||
* public no-arg constructor
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
private Constructor<?> getConstructor(Class<?> clazz) {
|
||||
PrivilegedExceptionAction<Constructor<?>> pa
|
||||
= new PrivilegedExceptionAction<>() {
|
||||
|
@ -685,12 +691,13 @@ public final class ServiceLoader<S>
|
|||
final Class<? extends S> type;
|
||||
final Method factoryMethod; // factory method or null
|
||||
final Constructor<? extends S> ctor; // public no-args constructor or null
|
||||
@SuppressWarnings("removal")
|
||||
final AccessControlContext acc;
|
||||
|
||||
ProviderImpl(Class<S> service,
|
||||
Class<? extends S> type,
|
||||
Method factoryMethod,
|
||||
AccessControlContext acc) {
|
||||
@SuppressWarnings("removal") AccessControlContext acc) {
|
||||
this.service = service;
|
||||
this.type = type;
|
||||
this.factoryMethod = factoryMethod;
|
||||
|
@ -701,7 +708,7 @@ public final class ServiceLoader<S>
|
|||
ProviderImpl(Class<S> service,
|
||||
Class<? extends S> type,
|
||||
Constructor<? extends S> ctor,
|
||||
AccessControlContext acc) {
|
||||
@SuppressWarnings("removal") AccessControlContext acc) {
|
||||
this.service = service;
|
||||
this.type = type;
|
||||
this.factoryMethod = null;
|
||||
|
@ -729,6 +736,7 @@ public final class ServiceLoader<S>
|
|||
* permissions that are restricted by the security context of whatever
|
||||
* created this loader.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
private S invokeFactoryMethod() {
|
||||
Object result = null;
|
||||
Throwable exc = null;
|
||||
|
@ -772,6 +780,7 @@ public final class ServiceLoader<S>
|
|||
* with a security manager then the constructor runs with permissions that
|
||||
* are restricted by the security context of whatever created this loader.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
private S newInstance() {
|
||||
S p = null;
|
||||
Throwable exc = null;
|
||||
|
@ -835,6 +844,7 @@ public final class ServiceLoader<S>
|
|||
* isn't the expected sub-type (or doesn't define a provider
|
||||
* factory method that returns the expected type)
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
private Provider<S> loadProvider(ServiceProvider provider) {
|
||||
Module module = provider.module();
|
||||
if (!module.canRead(service.getModule())) {
|
||||
|
@ -1003,6 +1013,7 @@ public final class ServiceLoader<S>
|
|||
/**
|
||||
* Returns the class loader that a module is defined to
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
private ClassLoader loaderFor(Module module) {
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm == null) {
|
||||
|
@ -1255,6 +1266,7 @@ public final class ServiceLoader<S>
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
if (acc == null) {
|
||||
|
@ -1267,6 +1279,7 @@ public final class ServiceLoader<S>
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
@Override
|
||||
public Provider<T> next() {
|
||||
if (acc == null) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue