diff --git a/src/java.base/share/classes/jdk/internal/misc/InnocuousThread.java b/src/java.base/share/classes/jdk/internal/misc/InnocuousThread.java index 056350f25c39f57d038ac1b459c4f162561535c3..e62a0321a7fe67407652a31f0a382e78af0ed8a8 100644 --- a/src/java.base/share/classes/jdk/internal/misc/InnocuousThread.java +++ b/src/java.base/share/classes/jdk/internal/misc/InnocuousThread.java @@ -62,10 +62,16 @@ public final class InnocuousThread extends Thread { * 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() { + @Override + public Thread run() { + return new InnocuousThread(INNOCUOUSTHREADGROUP, + target, + name, + ClassLoader.getSystemClassLoader()); + } + }); } /** @@ -80,8 +86,14 @@ public final class InnocuousThread extends Thread { * 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() { + @Override + public Thread run() { + return new InnocuousThread(INNOCUOUSTHREADGROUP, + target, name, null); + } + }); } private InnocuousThread(ThreadGroup group, Runnable target, String name, ClassLoader tccl) {