JDK-8355008 : Common ForkJoinPool uses InnocuousForkJoinWorkerThread, breaking setContextClassLoader
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.concurrent
  • Affected Version: 21.0.6
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: linux
  • Submitted: 2025-04-18
  • Updated: 2025-05-21
Related Reports
Causes :  
Description
When using a build of JDK 21.0.6.7.1 or 21.0.7.6.1 on linux and running with param `-Djava.security.manager=allow`, the changes made by JDK-8342905 and JDK-8344993 introduce a regression. This behavior is not present prior to those commits (with JDK  21.0.5.11.1).

To reproduce: 
1. Build JDK
2. Create App.java:
```
public class App {
    public static void main(String[] args) {
        var defaultExecutor = ForkJoinPool.commonPool();
        defaultExecutor.execute(() -> {
            Thread t = Thread.currentThread();
            System.out.println("Running in thread: " + t.getClass().getName());

            try {
                t.setContextClassLoader(new java.net.URLClassLoader(new java.net.URL[0]));
                System.out.println("Set context class loader.");
            } catch (SecurityException e) {
                System.err.println("SecurityException: " + e.getMessage());
                e.printStackTrace();
            }
        });

        try {
            Thread.sleep(1_000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}
```
3. Run `javac App.java`
4. Run `java -Djava.security.manager=allow App`

Comments
[~ssubramaniam] Are you able to provide more information? As the issue is formulated right now, it's not an issue, so without further information this issue is likely to get closed with no action.
21-05-2025

[~ssubramaniam] "In the JDK implementation, if the Java virtual machine is started with the java.security.manager system property set to the special token "allow", then a security manager will not be set at startup but can be set dynamically. " - https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/SecurityManager.html The example in this Issue is not setting a security manager, could you clarify what behavior you are expecting (and why).
06-05-2025

[~ssubramaniam] The issue does not explain what occurs. Would you be able to clarify?
30-04-2025

The security manager was permanently disabled in JDK 24 so I assume this issue is not applicable to JDK 24 and newer.
30-04-2025