Skip to content

Commit 872ae13

Browse files
Viktor KlangAlan Bateman
authored andcommitted
8342905: Thread.setContextClassloader from thread in FJP commonPool task no longer works after JDK-8327501 redux
Reviewed-by: alanb
1 parent 309ef3f commit 872ae13

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
import java.util.function.Predicate;
5252
import java.util.concurrent.CountDownLatch;
5353
import java.util.concurrent.locks.LockSupport;
54+
55+
import jdk.internal.access.JavaLangAccess;
5456
import jdk.internal.access.JavaUtilConcurrentFJPAccess;
5557
import jdk.internal.access.SharedSecrets;
5658
import jdk.internal.misc.Unsafe;
@@ -1133,9 +1135,7 @@ static final class DefaultForkJoinWorkerThreadFactory
11331135
implements ForkJoinWorkerThreadFactory {
11341136
public final ForkJoinWorkerThread newThread(ForkJoinPool pool) {
11351137
boolean isCommon = (pool.workerNamePrefix == null);
1136-
@SuppressWarnings("removal")
1137-
SecurityManager sm = System.getSecurityManager();
1138-
if (sm != null && isCommon)
1138+
if (isCommon && JLA.allowSecurityManager())
11391139
return newCommonWithACC(pool);
11401140
else
11411141
return newRegularWithACC(pool);
@@ -1152,6 +1152,8 @@ public final ForkJoinWorkerThread newThread(ForkJoinPool pool) {
11521152
@SuppressWarnings("removal")
11531153
static volatile AccessControlContext regularACC, commonACC;
11541154

1155+
private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess();
1156+
11551157
@SuppressWarnings("removal")
11561158
static ForkJoinWorkerThread newRegularWithACC(ForkJoinPool pool) {
11571159
AccessControlContext acc = regularACC;

0 commit comments

Comments
 (0)