-
Bug
-
Resolution: Fixed
-
P4
-
8, 11, 17, 18, 19, 20, 21
-
b16
-
generic
-
generic
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
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
- csr for
-
JDK-8304533 Add new lint flag "output-file-clash"
- Closed
- duplicates
-
JDK-8339308 Case Sensitivity Issue in Compiling Classes Named Sample and sample
- Closed
- relates to
-
JDK-8310067 Restore javac manpage updates
- Resolved
-
JDK-8287885 Local classes cause ClassLoader error if the type names are similar but not same
- Resolved
(1 links to)