提交 c008dc6a 编写于 作者: C chegar

8190482: InnocuousThread creation should not require the caller to possess...

8190482: InnocuousThread creation should not require the caller to possess enableContextClassLoaderOverride
Reviewed-by: rriggs, mchung
上级 b48c7a30
...@@ -62,11 +62,17 @@ public final class InnocuousThread extends Thread { ...@@ -62,11 +62,17 @@ public final class InnocuousThread extends Thread {
* set to the system class loader. * set to the system class loader.
*/ */
public static Thread newThread(String name, Runnable target) { public static Thread newThread(String name, Runnable target) {
return AccessController.doPrivileged(
new PrivilegedAction<Thread>() {
@Override
public Thread run() {
return new InnocuousThread(INNOCUOUSTHREADGROUP, return new InnocuousThread(INNOCUOUSTHREADGROUP,
target, target,
name, name,
ClassLoader.getSystemClassLoader()); ClassLoader.getSystemClassLoader());
} }
});
}
/** /**
* Returns a new InnocuousThread with an auto-generated thread name. * Returns a new InnocuousThread with an auto-generated thread name.
...@@ -80,9 +86,15 @@ public final class InnocuousThread extends Thread { ...@@ -80,9 +86,15 @@ public final class InnocuousThread extends Thread {
* Returns a new InnocuousThread with null context class loader. * Returns a new InnocuousThread with null context class loader.
*/ */
public static Thread newSystemThread(String name, Runnable target) { public static Thread newSystemThread(String name, Runnable target) {
return AccessController.doPrivileged(
new PrivilegedAction<Thread>() {
@Override
public Thread run() {
return new InnocuousThread(INNOCUOUSTHREADGROUP, return new InnocuousThread(INNOCUOUSTHREADGROUP,
target, name, null); target, name, null);
} }
});
}
private InnocuousThread(ThreadGroup group, Runnable target, String name, ClassLoader tccl) { private InnocuousThread(ThreadGroup group, Runnable target, String name, ClassLoader tccl) {
super(group, target, name, 0L, false); super(group, target, name, 0L, false);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册