8190482: InnocuousThread creation should not require the caller to possess enableContextClassLoaderOverride
Reviewed-by: rriggs, mchung
--- a/src/java.base/share/classes/jdk/internal/misc/InnocuousThread.java Tue Nov 07 12:18:29 2017 +0100
+++ b/src/java.base/share/classes/jdk/internal/misc/InnocuousThread.java Tue Nov 07 17:08:59 2017 +0000
@@ -62,10 +62,16 @@
* set to the system class loader.
*/
public static Thread newThread(String name, Runnable target) {
- return new InnocuousThread(INNOCUOUSTHREADGROUP,
- target,
- name,
- ClassLoader.getSystemClassLoader());
+ return AccessController.doPrivileged(
+ new PrivilegedAction<Thread>() {
+ @Override
+ public Thread run() {
+ return new InnocuousThread(INNOCUOUSTHREADGROUP,
+ target,
+ name,
+ ClassLoader.getSystemClassLoader());
+ }
+ });
}
/**
@@ -80,8 +86,14 @@
* Returns a new InnocuousThread with null context class loader.
*/
public static Thread newSystemThread(String name, Runnable target) {
- return new InnocuousThread(INNOCUOUSTHREADGROUP,
- target, name, null);
+ return AccessController.doPrivileged(
+ new PrivilegedAction<Thread>() {
+ @Override
+ public Thread run() {
+ return new InnocuousThread(INNOCUOUSTHREADGROUP,
+ target, name, null);
+ }
+ });
}
private InnocuousThread(ThreadGroup group, Runnable target, String name, ClassLoader tccl) {