langtools/test/tools/javac/defaultMethods/private/Private03.java
changeset 29293 1583c6dd6df7
equal deleted inserted replaced
29292:c10d63c667cd 29293:1583c6dd6df7
       
     1 /*
       
     2  * @test   /nodynamiccopyright/
       
     3  * @bug    8071453
       
     4  * @author sadayapalam
       
     5  * @summary Various tests for private methods in interfaces.
       
     6  * @compile/fail/ref=Private03.out -XDrawDiagnostics Private03.java
       
     7  */
       
     8 
       
     9 
       
    10 public class Private03 {
       
    11     interface I {
       
    12         private void foo(int x) {}
       
    13         private void goo(int x) {}
       
    14     }
       
    15 
       
    16     interface J extends I {
       
    17         // Verify that we are able to declare a public abstract method with the same signature as a private method in super type.
       
    18         void foo(int x);
       
    19         // Verify that we are able to declare a public default method with the same signature as a private method in super type.
       
    20         default void goo(int x) {}
       
    21     }
       
    22 
       
    23     interface K extends J {
       
    24         private void foo(int x) {} // Error, cannot reduce visibility
       
    25         private void goo(int x) {} // Ditto.
       
    26     }
       
    27 }