|
1 /* |
|
2 * @test /nodynamiccopyright/ |
|
3 * @bug 4018525 4059072 4277274 4785453 |
|
4 * @summary Test that recursive 'extends' and 'implements' clauses are detected |
|
5 * and disallowed. |
|
6 * |
|
7 * @compile/fail/ref=CyclicInheritance.out -XDrawDiagnostics CyclicInheritance.java |
|
8 */ |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 class C1 extends C1 {} // ERROR - Cyclic inheritance |
|
16 |
|
17 class C11 extends C12 {} // ERROR - Cyclic inheritance |
|
18 class C12 extends C11 {} // error in previous line could correctly be reported here as well |
|
19 |
|
20 interface I1 extends I1 {} // ERROR - Cyclic inheritance |
|
21 |
|
22 interface I11 extends I12 {} // ERROR - Cyclic inheritance |
|
23 interface I12 extends I11 {} // error in previous line could correctly be reported here as well |
|
24 |
|
25 //----- |
|
26 |
|
27 class C211 implements C211.I { // ERROR - may change pending resoluation of 4087020 |
|
28 interface I {}; // error in previous line could correctly be reported here as well |
|
29 } |
|
30 |
|
31 class C212 extends C212.C { // ERROR - Cyclic inheritance, subclass cannot enclose superclass |
|
32 static class C {}; // error in previous line could correctly be reported here as well |
|
33 } |
|
34 |
|
35 |
|
36 class C221 implements C221.I { // ERROR - Cannot access C21 (private) |
|
37 private interface I {}; // error in previous line could correctly be reported here as well |
|
38 } |
|
39 |
|
40 class C222 extends C222.C { // ERROR - Cannot access C22 (private) |
|
41 private static class C {}; // error in previous line could correctly be reported here as well |
|
42 } |
|
43 |
|
44 //----- |
|
45 |
|
46 class C3 { |
|
47 class A { |
|
48 class B extends A {} |
|
49 } |
|
50 } |
|
51 |
|
52 class C4 { |
|
53 class A extends B {} |
|
54 class B { |
|
55 class C extends A {} |
|
56 } |
|
57 } |