Fri, 24 Apr 2020 03:58:51 +0100
Merge
1 /**
2 * @test /nodynamiccopyright/
3 * @bug 4094658 4277300 4785453
4 * @summary Test enforcement of JLS 6.6.1 and 6.6.2 rules requiring that
5 * the type to which a component member belongs be accessible in qualified
6 * names.
7 *
8 * @compile pack1/P1.java
9 * @compile pack1/P2.java
10 * @compile/fail/ref=QualifiedAccess_2.out -XDrawDiagnostics QualifiedAccess_2.java
11 */
13 import pack1.P1;
15 class A {
16 private static class B {
17 static class Inner {}
18 }
19 }
21 class X extends pack1.P1 {
22 X() { super("bar"); }
23 void foo() {
24 /*-----------------*
25 // BOGUS: Reports matching constructor not found.
26 // OK if 'Q' is made a public constructor.
27 Object y = new Q("foo");// ERROR - protected constructor Q inaccessible
28 *------------------*/
29 // Reports 'P1.R.S' not found at all. (private)
30 Object z = new R.S.T(); // ERROR - S is inaccessible
31 }
32 }
34 class Y {
36 class Foo {
37 class Bar {}
38 }
40 class C extends A.B {} // ERROR - B is inaccessible
41 class D extends A.B.Inner {} // ERROR - B is inaccessible
43 static class Quux {
44 private static class Quem {
45 P1.Foo.Bar x; // ERROR - Foo is inaccessible
46 static class MyError extends Error {}
47 }
48 }
49 }
51 class Z {
52 void foo() throws Y.Quux.Quem.MyError {
53 // ERROR - type of Quux not accesible (private)
54 throw new Y.Quux.Quem.MyError();
55 // ERROR - type of Quux not accesible (private)
56 }
57 }