test/tools/javac/CyclicInheritance.java

changeset 1
9a66ca7c79fa
child 69
82c7aa6fe50a
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/tools/javac/CyclicInheritance.java	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,57 @@
     1.4 +/*
     1.5 + * @test  /nodynamiccopyright/
     1.6 + * @bug 4018525 4059072 4277274 4785453
     1.7 + * @summary Test that recursive 'extends' and 'implements' clauses are detected
     1.8 + * and disallowed.
     1.9 + *
    1.10 + * @run shell CyclicInheritance.sh
    1.11 + */
    1.12 +
    1.13 +
    1.14 +
    1.15 +
    1.16 +
    1.17 +
    1.18 +class C1 extends C1 {}                  // ERROR - Cyclic inheritance
    1.19 +
    1.20 +class C11 extends C12 {}                // ERROR - Cyclic inheritance
    1.21 +class C12 extends C11 {}                // error in previous line could correctly be reported here as well
    1.22 +
    1.23 +interface I1 extends I1 {}              // ERROR - Cyclic inheritance
    1.24 +
    1.25 +interface I11 extends I12 {}            // ERROR - Cyclic inheritance
    1.26 +interface I12 extends I11 {}            // error in previous line could correctly be reported here as well
    1.27 +
    1.28 +//-----
    1.29 +
    1.30 +class C211 implements C211.I {          // ERROR - may change pending resoluation of 4087020
    1.31 +        interface I {};                 // error in previous line could correctly be reported here as well
    1.32 +}
    1.33 +
    1.34 +class C212 extends C212.C {             // ERROR - Cyclic inheritance, subclass cannot enclose superclass
    1.35 +        static class C {};              // error in previous line could correctly be reported here as well
    1.36 +}
    1.37 +
    1.38 +
    1.39 +class C221 implements C221.I {          // ERROR - Cannot access C21 (private)
    1.40 +        private interface I {};         // error in previous line could correctly be reported here as well
    1.41 +}
    1.42 +
    1.43 +class C222 extends C222.C {             // ERROR - Cannot access C22 (private)
    1.44 +        private static class C {};      // error in previous line could correctly be reported here as well
    1.45 +}
    1.46 +
    1.47 +//-----
    1.48 +
    1.49 +class C3 {
    1.50 +    class A {
    1.51 +        class B extends A {}
    1.52 +    }
    1.53 +}
    1.54 +
    1.55 +class C4 {
    1.56 +    class A extends B {}
    1.57 +    class B {
    1.58 +        class C extends A {}
    1.59 +    }
    1.60 +}

mercurial