commit f21b0a990905afe79b56919a5119e2c06e29d61a Author: Andrew John Hughes Date: Sat Oct 12 02:31:38 2024 +0100 Revert "8327501: Common ForkJoinPool prevents class unloading in some cases" This reverts commit eb103b0e1abeeee19779cafc763d3d159030fb48. diff --git a/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java b/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java index 8aafda5312e..5e698b1540f 100644 --- a/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java +++ b/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java @@ -981,7 +981,9 @@ public class ForkJoinPool extends AbstractExecutorService { boolean isCommon = (pool.workerNamePrefix == null); @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); - if (sm != null && isCommon) + if (sm == null) + return new ForkJoinWorkerThread(null, pool, true, false); + else if (isCommon) return newCommonWithACC(pool); else return newRegularWithACC(pool); diff --git a/test/jdk/java/util/concurrent/tck/ForkJoinPool9Test.java b/test/jdk/java/util/concurrent/tck/ForkJoinPool9Test.java index a87aa7b916b..266c2a036fe 100644 --- a/test/jdk/java/util/concurrent/tck/ForkJoinPool9Test.java +++ b/test/jdk/java/util/concurrent/tck/ForkJoinPool9Test.java @@ -79,9 +79,6 @@ public class ForkJoinPool9Test extends JSR166TestCase { assertSame(ForkJoinPool.commonPool(), ForkJoinTask.getPool()); Thread currentThread = Thread.currentThread(); - ClassLoader preexistingContextClassLoader = - currentThread.getContextClassLoader(); - Stream.of(systemClassLoader, null).forEach(cl -> { if (randomBoolean()) // should always be permitted, without effect @@ -98,11 +95,6 @@ public class ForkJoinPool9Test extends JSR166TestCase { () -> System.getProperty("foo"), () -> currentThread.setContextClassLoader( classLoaderDistinctFromSystemClassLoader)); - else { - currentThread.setContextClassLoader(classLoaderDistinctFromSystemClassLoader); - assertSame(currentThread.getContextClassLoader(), classLoaderDistinctFromSystemClassLoader); - currentThread.setContextClassLoader(preexistingContextClassLoader); - } // TODO ? // if (haveSecurityManager // && Thread.currentThread().getClass().getSimpleName()