Wed, 26 Jan 2011 13:45:25 -0800
7013272: Automatically generate info about how compiler resource keys are used
Reviewed-by: mcimadamore
1 /*
2 * @test /nodynamiccopyright/
3 * @bug 4319507 4785453
4 * @summary Verify correct implementation of JLS2e 6.6.2.1
5 * @author maddox
6 *
7 * @compile/fail/ref=ProtectedMemberAccess2.out -XDdiags=-simpleNames -XDdiagsFormat=%b:%l:%_%m ProtectedMemberAccess2.java
8 */
10 // 71 errors expected.
12 import pkg.SuperClass;
14 class ProtectedMemberAccess2 {
16 // Since this class is not a subclass of the class in which the
17 // protected members are declared, all of the accesses are illegal.
19 pkg.SuperClass x = new pkg.SuperClass();
21 static pkg.SuperClass sx = new pkg.SuperClass();
23 int i = x.pi; // illegal
24 int j = x.spi; // illegal
26 int n = sx.pi; // illegal
27 int m = sx.spi; // illegal
29 static int sn = sx.pi; // illegal
30 static int sm = sx.spi; // illegal
32 int w = x.pm(); // illegal
33 int y = x.spm(); // illegal
35 int u = sx.pm(); // illegal
36 int v = sx.spm(); // illegal
38 pkg.SuperClass.pC obj1; // illegal
39 pkg.SuperClass.spC obj2; // illegal
41 pkg.SuperClass.pI obj3; // illegal
42 pkg.SuperClass.spI obj4; // illegal
44 Object o1 = (pkg.SuperClass.pC) null; // illegal
45 Object o2 = (pkg.SuperClass.spC) null; // illegal
47 Object o3 = (pkg.SuperClass.pI) null; // illegal
48 Object o4 = (pkg.SuperClass.spI) null; // illegal
50 class C1 extends pkg.SuperClass.pC {} // illegal
51 class C2 extends pkg.SuperClass.spC {} // illegal
53 interface I1 extends pkg.SuperClass.pI {} // illegal
54 interface I2 extends pkg.SuperClass.spI {} // illegal
56 static {
58 pkg.SuperClass lx = new pkg.SuperClass();
60 sx.pi = 1; // illegal
61 sx.spi = 2; // illegal
63 lx.pi = 1; // illegal
64 lx.spi = 2; // illegal
66 int n = sx.pi; // illegal
67 int m = sx.spi; // illegal
69 int k = lx.pi; // illegal
70 int l = lx.spi; // illegal
72 int u = sx.pm(); // illegal
73 int v = sx.spm(); // illegal
75 int w = lx.pm(); // illegal
76 int z = lx.spm(); // illegal
78 pkg.SuperClass.pC obj1; // illegal
79 pkg.SuperClass.spC obj2; // illegal
81 pkg.SuperClass.pI obj3; // illegal
82 pkg.SuperClass.spI obj4; // illegal
84 Object o1 = (pkg.SuperClass.pC) null; // illegal
85 Object o2 = (pkg.SuperClass.spC) null; // illegal
87 Object o3 = (pkg.SuperClass.pI) null; // illegal
88 Object o4 = (pkg.SuperClass.spI) null; // illegal
90 //class C1 extends pkg.SuperClass.pC {}
91 class C2 extends pkg.SuperClass.spC {} // illegal
93 //interface I1 extends pkg.SuperClass.pI {}
94 //interface I2 extends pkg.SuperClass.spI {}
96 }
98 void m() {
100 pkg.SuperClass lx = new pkg.SuperClass();
102 x.pi = 1; // illegal
103 x.spi = 2; // illegal
105 sx.pi = 1; // illegal
106 sx.spi = 2; // illegal
108 lx.pi = 1; // illegal
109 lx.spi = 2; // illegal
111 int t = x.pm(); // illegal
112 int y = x.spm(); // illegal
114 int u = sx.pm(); // illegal
115 int v = sx.spm(); // illegal
117 int w = lx.pm(); // illegal
118 int z = lx.spm(); // illegal
120 int i = x.pi; // illegal
121 int j = x.spi; // illegal
123 int n = sx.pi; // illegal
124 int m = sx.spi; // illegal
126 int k = lx.pi; // illegal
127 int l = lx.spi; // illegal
129 pkg.SuperClass.pC obj1; // illegal
130 pkg.SuperClass.spC obj2; // illegal
132 pkg.SuperClass.pI obj3; // illegal
133 pkg.SuperClass.spI obj4; // illegal
135 Object o1 = (pkg.SuperClass.pC) null; // illegal
136 Object o2 = (pkg.SuperClass.spC) null; // illegal
138 Object o3 = (pkg.SuperClass.pI) null; // illegal
139 Object o4 = (pkg.SuperClass.spI) null; // illegal
141 class C1 extends pkg.SuperClass.pC {} // illegal
142 class C2 extends pkg.SuperClass.spC {} // illegal
144 //interface I1 extends pkg.SuperClass.pI {}
145 //interface I2 extends pkg.SuperClass.spI {}
147 }
149 }