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 { poo()9 private void poo() {} foo()10 private int foo() { return 0; } goo()11 int goo(); doo()12 default int doo() { return foo(); } bad()13 private public int bad(); // 9.4 illegal combination of modifiers verybad()14 private abstract int verybad(); // 9.4 illegal combination of modifiers alsobad()15 private default int alsobad() { return foo(); } // 9.4 illegal combination of modifiers blah()16 protected void blah(); missingBody()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 { foo()24 default void foo() { // foo not inherited from super, change of return type is OK. 25 super.foo(); // super in static context - Error. 26 } doo()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 38