jdk-24/test/langtools/tools/javac/T8059921/ForbidAccessToFieldUsingSuperTest.java
2017-09-12 19:03:39 +02:00

32 lines
719 B
Java

/*
* @test /nodynamiccopyright/
* @bug 8059921
* @summary Missing compile error in Java 8 mode for Interface.super.field access
* @compile/fail/ref=ForbidAccessToFieldUsingSuperTest.out -XDrawDiagnostics ForbidAccessToFieldUsingSuperTest.java
*/
public class ForbidAccessToFieldUsingSuperTest {
class C {
int m() { return 0; }
}
interface T {
int f = 0;
C c = null;
default int mm() {
return 0;
}
}
interface T1 extends T {}
class X implements T1 {
int i = T1.super.f; //fail
int j = T1.super.c.m(); //fail
void foo(Runnable r) {
foo(T1.super::mm); //should'n fail
}
}
}