author | sogoel |
Thu, 05 Jun 2014 10:57:10 -0700 | |
changeset 24797 | 850ebd4d80a7 |
parent 6150 | d055fa8ced62 |
permissions | -rw-r--r-- |
10 | 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 |
* |
|
863
3113c955a388
6724327: eliminate use of shell tests for simple golden file tests
jjg
parents:
10
diff
changeset
|
8 |
* @compile pack1/P1.java |
3113c955a388
6724327: eliminate use of shell tests for simple golden file tests
jjg
parents:
10
diff
changeset
|
9 |
* @compile pack1/P2.java |
6150 | 10 |
* @compile/fail/ref=QualifiedAccess_2.out -XDrawDiagnostics QualifiedAccess_2.java |
10 | 11 |
*/ |
12 |
||
13 |
import pack1.P1; |
|
14 |
||
15 |
class A { |
|
16 |
private static class B { |
|
17 |
static class Inner {} |
|
18 |
} |
|
19 |
} |
|
20 |
||
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 |
} |
|
33 |
||
34 |
class Y { |
|
35 |
||
36 |
class Foo { |
|
37 |
class Bar {} |
|
38 |
} |
|
39 |
||
40 |
class C extends A.B {} // ERROR - B is inaccessible |
|
41 |
class D extends A.B.Inner {} // ERROR - B is inaccessible |
|
42 |
||
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 |
} |
|
50 |
||
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 |
} |