Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8355008

Common ForkJoinPool uses InnocuousForkJoinWorkerThread, breaking setContextClassLoader

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 21.0.6
    • core-libs
    • linux

      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`

            Unassigned Unassigned
            ssubramaniam Satyen Subramaniam
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: