equal
deleted
inserted
replaced
|
1 /* @test /nodynamiccopyright/ |
|
2 * @bug 8071453 |
|
3 * @author sadayapalam |
|
4 * @summary Test various JLS changes made for supporting private interface methods. |
|
5 * @compile/fail/ref=Private08.out -XDrawDiagnostics Private08.java |
|
6 */ |
|
7 class Private08 { |
|
8 interface I { |
|
9 private void poo() {} |
|
10 private int foo() { return 0; } |
|
11 int goo(); |
|
12 default int doo() { return foo(); } |
|
13 private public int bad(); // 9.4 illegal combination of modifiers |
|
14 private abstract int verybad(); // 9.4 illegal combination of modifiers |
|
15 private default int alsobad() { return foo(); } // 9.4 illegal combination of modifiers |
|
16 protected void blah(); |
|
17 private void missingBody(); // private methods are not abstract. |
|
18 } |
|
19 } |
|
20 |
|
21 class Private08_01 { |
|
22 int y = ((Private08.I) null).foo(); // 9.4 test that private methods are not implicitly public. |
|
23 interface J extends Private08.I { |
|
24 default void foo() { // foo not inherited from super, change of return type is OK. |
|
25 super.foo(); // super in static context - Error. |
|
26 } |
|
27 private int doo() { return 0; } // private cannot override public. |
|
28 }; |
|
29 |
|
30 Private08.I i = new Private08.I () { |
|
31 public void foo() { // foo not inherited from super, change of return type is OK. |
|
32 super.foo(); // super's foo not inherited, NOT OK. |
|
33 } |
|
34 private int doo() { return 0; } // private cannot override public. |
|
35 }; // should not complain about poo() not being implemented. |
|
36 } |
|
37 |