JDK 21 |
---|
21 b16Fixed |
CSR :
|
|
Duplicate :
|
|
Relates :
|
|
Relates :
|
JDK-8304995 :
|
ADDITIONAL SYSTEM INFORMATION : x86/windows 10/ openjdk 19.0.1 A DESCRIPTION OF THE PROBLEM : Getting java.lang.NoClassDefFoundError exception on running fully legitimate code STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : run this snippet public interface Main { @interface Annotation { interface foo { static void print() {System.out.println("Oops!");} } @interface Foo {} } static void main(String[] args) { Annotation.foo.print(); } } EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - Ooops in the console ACTUAL - Exception in thread "main" java.lang.NoClassDefFoundError: Main$Annotation$Foo (wrong name: Main$Annotation$foo) at java.base/java.lang.ClassLoader.defineClass1(Native Method) at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1013) at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150) at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862) at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) at Main.main(Main.java:13) ---------- BEGIN SOURCE ---------- public interface Main { @interface Annotation { interface foo { static void print() {System.out.println("Oops!");} } @interface Foo {} } static void main(String[] args) { Annotation.foo.print(); } } ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : rename foo or Foo to something else
|