-
Bug
-
Resolution: Fixed
-
P3
-
22, 23
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
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
- relates to
-
JDK-8315458 Implement JEP 463: Implicitly Declared Classes and Instance Main Method (Second Preview)
- Resolved
-
JDK-8333714 Cleanup the usages of CHECK_EXCEPTION_NULL_FAIL macro in java launcher
- Resolved
-
JDK-8329420 Java 22 (and 23) launcher calls default constructor although main() is static
- Resolved
-
JDK-8330864 No error message when ExceptionInInitializerError thrown in static initializer
- Resolved
-
JDK-8336965 Initializing a static Set using Set.of() causes JVM to exit before entering main
- Closed
(2 links to)