JDK-8329581 : Java launcher no longer prints a stack trace
  • Type: Bug
  • Component: tools
  • Sub-Component: launcher
  • Affected Version: 22,23
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2024-04-02
  • Updated: 2024-07-17
  • Resolved: 2024-06-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 23
23 b26Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
Windows Oracle JDK22

A DESCRIPTION OF THE PROBLEM :
JDK22 does not have the same built-in default stack trace handling for running a main method of a class which cannot be loaded because a dependency is missing. The same issue occurs if classes are in different jars (such as missing a jar for logger implementation)

REGRESSION : Last worked in version 21

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the Demo.java class below with JDK17 and test it works JDK17 and JDK22
jdk-17\bin\javac -d classes Demo.java
jdk-17\bin\java -cp classes Demo
jdk-22\bin\java -cp classes Demo
Then delete the referenced class and re-run:
   del classes\Demo$SomeDependency.class
jdk-17\bin\java -cp classes Demo
jdk-22\bin\java -cp classes Demo



EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Run in JDK17...JDK21 reports ClassNotFoundException as expected
jdk-17\bin\java -cp classes Demo
Exception in thread "main" java.lang.NoClassDefFoundError: Demo$SomeDependency
        at Demo.<clinit>(Demo.java:10)
Caused by: java.lang.ClassNotFoundException: Demo$SomeDependency
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)

ACTUAL -
Re-run in JDK22 prints nothing:
	\java\jdk-22\bin\java -cp classes Demo


---------- BEGIN SOURCE ----------
// Save as Demo.java. 
public class Demo {
    static class SomeDependency {}
    private static final SomeDependency X = new SomeDependency();
    public static void main(String... args)  {
        System.out.println("X="+X);
    }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
None. 

FREQUENCY : always



Comments
Changeset: cbb6747e Author: Sonia Zaldana Calles <szaldana@openjdk.org> Committer: Jaikiran Pai <jpai@openjdk.org> Date: 2024-06-05 13:12:30 +0000 URL: https://git.openjdk.org/jdk/commit/cbb6747e6b9ce7e2b9e0ffb0a1f9499f7e0e13b0
05-06-2024

Regression seems to have been introduced with JDK-8315458. Linking the issue.
16-04-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/18786 Date: 2024-04-15 18:25:02 +0000
15-04-2024

Observation on Windows 11 ----------------------------------------- JDK 21.0.2+13-LTS-58 : Passed (Stack trace printed with ClassNotFoundException) JDK 22: Failed (No stack trace) JDK 23-ea+6-400 : Failed
03-04-2024