diff options
| author | Weijun Wang <weijun@openjdk.org> | 2021-06-02 11:57:31 +0000 |
|---|---|---|
| committer | Weijun Wang <weijun@openjdk.org> | 2021-06-02 11:57:31 +0000 |
| commit | 6765f902505fbdd02f25b599f942437cd805cad1 (patch) | |
| tree | 10f17ab758cb026fc868edf607f64a879e216a45 /src/java.base/share/classes/java/lang/Thread.java | |
| parent | 19450b99512ce4ad4ab41be5034806e2c9dbcd59 (diff) | |
| download | openjdk-6765f902505fbdd02f25b599f942437cd805cad1.tar.gz openjdk-6765f902505fbdd02f25b599f942437cd805cad1.zip | |
8266459: Implement JEP 411: Deprecate the Security Manager for Removaljdk-17+25
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
Diffstat (limited to 'src/java.base/share/classes/java/lang/Thread.java')
| -rw-r--r-- | src/java.base/share/classes/java/lang/Thread.java | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/java.base/share/classes/java/lang/Thread.java b/src/java.base/share/classes/java/lang/Thread.java index a825a52e351..c13b42c2f6f 100644 --- a/src/java.base/share/classes/java/lang/Thread.java +++ b/src/java.base/share/classes/java/lang/Thread.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 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 @@ -169,6 +169,7 @@ public class Thread implements Runnable { private ClassLoader contextClassLoader; /* The inherited AccessControlContext of this thread */ + @SuppressWarnings("removal") private AccessControlContext inheritedAccessControlContext; /* For autonumbering anonymous threads. */ @@ -388,6 +389,7 @@ public class Thread implements Runnable { * @param inheritThreadLocals if {@code true}, inherit initial values for * inheritable thread-locals from the constructing thread */ + @SuppressWarnings("removal") private Thread(ThreadGroup g, Runnable target, String name, long stackSize, AccessControlContext acc, boolean inheritThreadLocals) { @@ -496,7 +498,7 @@ public class Thread implements Runnable { * but thread-local variables are not inherited. * This is not a public constructor. */ - Thread(Runnable target, AccessControlContext acc) { + Thread(Runnable target, @SuppressWarnings("removal") AccessControlContext acc) { this(null, target, "Thread-" + nextThreadNum(), 0, acc, false); } @@ -922,6 +924,7 @@ public class Thread implements Runnable { */ @Deprecated(since="1.2") public final void stop() { + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (security != null) { checkAccess(); @@ -1424,8 +1427,16 @@ public class Thread implements Runnable { * @throws SecurityException if the current thread is not allowed to * access this thread. * @see SecurityManager#checkAccess(Thread) + * @deprecated This method is only useful in conjunction with + * {@linkplain SecurityManager the Security Manager}, which is + * deprecated and subject to removal in a future release. + * Consequently, this method is also deprecated and subject to + * removal. There is no replacement for the Security Manager or this + * method. */ + @Deprecated(since="17", forRemoval=true) public final void checkAccess() { + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkAccess(this); @@ -1476,6 +1487,7 @@ public class Thread implements Runnable { public ClassLoader getContextClassLoader() { if (contextClassLoader == null) return null; + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { ClassLoader.checkClassLoaderPermission(contextClassLoader, @@ -1507,6 +1519,7 @@ public class Thread implements Runnable { * @since 1.2 */ public void setContextClassLoader(ClassLoader cl) { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new RuntimePermission("setContextClassLoader")); @@ -1574,6 +1587,7 @@ public class Thread implements Runnable { public StackTraceElement[] getStackTrace() { if (this != Thread.currentThread()) { // check for getStackTrace permission + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission( @@ -1634,6 +1648,7 @@ public class Thread implements Runnable { */ public static Map<Thread, StackTraceElement[]> getAllStackTraces() { // check for getStackTrace permission + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission( @@ -1696,6 +1711,7 @@ public class Thread implements Runnable { * subclass overrides any of the methods, false otherwise. */ private static boolean auditSubclass(final Class<?> subcl) { + @SuppressWarnings("removal") Boolean result = AccessController.doPrivileged( new PrivilegedAction<>() { public Boolean run() { @@ -1927,6 +1943,7 @@ public class Thread implements Runnable { * @since 1.5 */ public static void setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler eh) { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission( |
