langtools/test/tools/javac/defaultMethods/private/Private02.java
author sadayapalam
Mon, 02 Mar 2015 10:41:08 +0530
changeset 29293 1583c6dd6df7
permissions -rw-r--r--
8071453: Allow interface methods to be private Reviewed-by: mcimadamore Contributed-by: maurizio.cimadamore@oracle.com, srikanth.adayapalam@oracle.com

/*
 * @test   /nodynamiccopyright/
 * @bug    8071453
 * @author sadayapalam
 * @summary Various tests for private methods in interfaces.
 * @compile/fail/ref=Private02.out -XDrawDiagnostics Private02.java
 */


public class Private02 {
    interface I {
        private void foo(String s); // Error: private method must declare body.
        private abstract void foo(int i, int j); // Error: private & abstract: bad combo
        void foo(int x); // OK.
        private I foo() { return null; } // OK.
        private void foo(int x) {} // Name clash.
    }
    interface J extends I {
        private J foo() { return null; } // OK.
    }
    interface K extends J {
        void foo(); // OK
    }
}