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

NoClassDefFoundError for MethodType in recursive main call with try-finally

XMLWordPrintable

    • x86_64
    • linux_ubuntu

      ADDITIONAL SYSTEM INFORMATION :

      wsl2-ubuntu 22.04
      Linux 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

      java version "1.8.0_451"
      Java(TM) SE Runtime Environment (build 1.8.0_451-b10)
      Java HotSpot(TM) 64-Bit Server VM (build 25.451-b10, mixed mode)

      java version "11.0.27" 2025-04-15 LTS
      Java(TM) SE Runtime Environment 18.9 (build 11.0.27+8-LTS-232)
      Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.27+8-LTS-232, mixed mode)

      java version "17.0.15" 2025-04-15 LTS
      Java(TM) SE Runtime Environment (build 17.0.15+9-LTS-241)
      Java HotSpot(TM) 64-Bit Server VM (build 17.0.15+9-LTS-241, mixed mode, sharing)

      java version "21.0.7" 2025-04-15 LTS
      Java(TM) SE Runtime Environment (build 21.0.7+8-LTS-245)
      Java HotSpot(TM) 64-Bit Server VM (build 21.0.7+8-LTS-245, mixed mode, sharing)

      A DESCRIPTION OF THE PROBLEM :
      The following test program will throw java.lang.NoClassDefFoundError exception in JDK 11, 17 and 21. However, it executes normally in JDK 8.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Using JDK 11, 17, 21, run the following command:
      ```
      javac Test.java
      java Test
      ```

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The program should execute normally.
      ACTUAL -
      The program throws java.lang.NoClassDefFoundError exception.
      ```
      Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class java.lang.invoke.MethodType
              at Test.main(Test.java:5)
      ```

      ---------- BEGIN SOURCE ----------
      ```
      public class Test {
          public static void main(String[] args) {
              int result = runTest();
              System.err.println("Result = " + result);
          }
          public static int runTest() {
              try {
                  try {
                      main(null);
                  } finally {
                      return 2;
                  }
              } finally {
              }
          }
      }
      ```
      ---------- END SOURCE ----------

            eaymane EL Haimer Aymane
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: