FULL PRODUCT VERSION :
java version "9.0.1"
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Darwin Kernel Version 16.7.0: Mon Nov 13 21:56:25 PST 2017; root:xnu-3789.72.11~1/RELEASE_X86_64 x86_64
A DESCRIPTION OF THE PROBLEM :
The following code is compiled fine.
package a;
public class A {
public static void main(String[] args) {
new C().test();
}
private interface B {
private void test() {
}
}
static class C implements B {
void test() {
B.super.test();
}
}
}
But when you try to run this code, you will receive exception:
Exception in thread "main" java.lang.NoSuchFieldError: super
at a.A$C.test(A.java:15)
at a.A.main(A.java:5)
Apparently this code should not be compiled, as B.super.test(); construction is improper?
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Take code from description and compile it: javac a/A.java.
After that run the code:
bash-3.2$ java a.A
Exception in thread "main" java.lang.NoSuchFieldError: super
at a.A$C.test(A.java:15)
at a.A.main(A.java:5)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The code should not be compiled.
ACTUAL -
The code compiled fine.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.NoSuchFieldError: super
at a.A$C.test(A.java:15)
at a.A.main(A.java:5)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class A {
public static void main(String[] args) {
new C().test();
}
private interface B {
private void test() {
}
}
static class C implements B {
void test() {
B.super.test();
}
}
}
---------- END SOURCE ----------