RFR: 8368500: ContextClassLoader cannot be reset on threads in ForkJoinPool.commonPool()

Alan Bateman alanb at openjdk.org
Mon Oct 6 17:47:10 UTC 2025


On Mon, 6 Oct 2025 15:13:35 GMT, Johny Jose <duke at openjdk.org> wrote:

> The permanent disabling of the Security Manager in JDK 24  allow setCCL to set the CCL to a custom class loader. However, it doesn't allow it to be set to a custom class loader and then "reset" back to the system class loader before executing further code in the task. The changes are made to relax the restriction in setCCL to reset back to system class loader

The src change looks okay but the test isn't quire right at this time.

test/jdk/java/util/concurrent/forkjoin/ContextClassLoaderTest.java line 46:

> 44:     @Test
> 45:     void testContextClassLoaderIsSetAndRestored() throws InterruptedException {
> 46:         CountDownLatch latch = new CountDownLatch(1);

It looks like latch.await() is missing from the test.

test/jdk/java/util/concurrent/forkjoin/ContextClassLoaderTest.java line 70:

> 68:                         ((URLClassLoader) customCCL).close();
> 69:                     }
> 70:                 } catch (Exception ignored) {}

You can remove the customCCL.close,  there are no JAR/other resources to close.

-------------

PR Review: https://git.openjdk.org/jdk/pull/27648#pullrequestreview-3306265822
PR Review Comment: https://git.openjdk.org/jdk/pull/27648#discussion_r2407655983
PR Review Comment: https://git.openjdk.org/jdk/pull/27648#discussion_r2407659208


More information about the core-libs-dev mailing list