Sat, 22 Dec 2018 13:10:38 -0800
Added tag jdk8u202-b25 for changeset 15d8c732039b
vromero@2610 | 1 | /* |
vromero@2610 | 2 | * @test /nodynamiccopyright/ |
vromero@2610 | 3 | * @bug 8059921 |
vromero@2610 | 4 | * @summary Missing compile error in Java 8 mode for Interface.super.field access |
vromero@2610 | 5 | * @compile/fail/ref=ForbidAccessToFieldUsingSuperTest.out -XDrawDiagnostics ForbidAccessToFieldUsingSuperTest.java |
vromero@2610 | 6 | */ |
vromero@2610 | 7 | |
vromero@2610 | 8 | public class ForbidAccessToFieldUsingSuperTest { |
vromero@2610 | 9 | class C { |
vromero@2610 | 10 | int m() { return 0; } |
vromero@2610 | 11 | } |
vromero@2610 | 12 | |
vromero@2610 | 13 | interface T { |
vromero@2610 | 14 | int f = 0; |
vromero@2610 | 15 | C c = null; |
vromero@2610 | 16 | default int mm() { |
vromero@2610 | 17 | return 0; |
vromero@2610 | 18 | } |
vromero@2610 | 19 | } |
vromero@2610 | 20 | |
vromero@2610 | 21 | interface T1 extends T {} |
vromero@2610 | 22 | |
vromero@2610 | 23 | class X implements T1 { |
vromero@2610 | 24 | int i = T1.super.f; //fail |
vromero@2610 | 25 | int j = T1.super.c.m(); //fail |
vromero@2610 | 26 | |
vromero@2610 | 27 | void foo(Runnable r) { |
vromero@2610 | 28 | foo(T1.super::mm); //should'n fail |
vromero@2610 | 29 | } |
vromero@2610 | 30 | } |
vromero@2610 | 31 | } |