10
|
1 |
/*
|
|
2 |
* @test /nodynamiccopyright/
|
|
3 |
* @bug 4087314 4087314 4785453
|
|
4 |
* @summary Test access checking within 'extends' and 'implements' clause.
|
|
5 |
* @author William Maddox (maddox)
|
6150
|
6 |
* @compile/fail/ref=ExtendsAccess.out -XDrawDiagnostics ExtendsAccess.java
|
10
|
7 |
*/
|
|
8 |
|
|
9 |
/*
|
|
10 |
* Should compile with errors as noted.
|
|
11 |
*/
|
|
12 |
|
|
13 |
class ExtendsAccess {
|
|
14 |
|
|
15 |
class defaultClass { }
|
|
16 |
public class publicClass { }
|
|
17 |
private class privateClass { }
|
|
18 |
protected class protectedClass { }
|
|
19 |
|
|
20 |
static class defaultStaticClass { }
|
|
21 |
public static class publicStaticClass { }
|
|
22 |
private static class privateStaticClass { }
|
|
23 |
protected static class protectedStaticClass { }
|
|
24 |
|
|
25 |
interface defaultInterface { }
|
|
26 |
public interface publicInterface { }
|
|
27 |
private interface privateInterface { }
|
|
28 |
protected interface protectedInterface { }
|
|
29 |
}
|
|
30 |
|
|
31 |
class ExtendsAccess111 extends publicClass { } // ERROR - 'publicClass' not in scope
|
|
32 |
class ExtendsAccess112 extends defaultClass { } // ERROR - 'defaultClass' not in scope
|
|
33 |
class ExtendsAccess113 extends protectedClass { } // ERROR - 'protectedClass' not in scope
|
|
34 |
class ExtendsAccess114 extends privateClass { } // ERROR - 'privateClass' not in scope
|
|
35 |
|
|
36 |
class ExtendsAccess1211 extends ExtendsAccess.publicClass { } // OK - can extend inner classes (was ERROR - no enclosing instance)
|
|
37 |
class ExtendsAccess1221 extends ExtendsAccess.defaultClass { } // OK - can extend inner classes (was ERROR - no enclosing instance)
|
|
38 |
class ExtendsAccess1231 extends ExtendsAccess.protectedClass { } // OK - can extend inner classes (was ERROR - no enclosing instance)
|
|
39 |
class ExtendsAccess1241 extends ExtendsAccess.privateClass { } // ERROR - cannot access 'privateClass'
|
|
40 |
|
|
41 |
class ExtendsAccess1212 extends p.ExtendsAccess.publicClass { } // OK - can extend inner classes (was ERROR - no enclosing instance)
|
|
42 |
class ExtendsAccess1222 extends p.ExtendsAccess.defaultClass { } // ERROR - cannot access 'defaultClass'
|
|
43 |
class ExtendsAccess1232 extends p.ExtendsAccess.protectedClass { } // ERROR - cannot access 'protectedClass'
|
|
44 |
class ExtendsAccess1242 extends p.ExtendsAccess.privateClass { } // ERROR - cannot access 'privateClass'
|
|
45 |
|
|
46 |
class ExtendsAccess1311 extends ExtendsAccess {
|
|
47 |
class N extends publicClass { }
|
|
48 |
}
|
|
49 |
class ExtendsAccess1321 extends ExtendsAccess {
|
|
50 |
class N extends defaultClass { }
|
|
51 |
}
|
|
52 |
class ExtendsAccess1331 extends ExtendsAccess {
|
|
53 |
class N extends protectedClass { }
|
|
54 |
}
|
|
55 |
class ExtendsAccess1341 extends ExtendsAccess {
|
|
56 |
class N extends privateClass { } // ERROR - cannot access 'privateClass'
|
|
57 |
}
|
|
58 |
|
|
59 |
class ExtendsAccess1312 extends p.ExtendsAccess {
|
|
60 |
class N extends publicClass { }
|
|
61 |
}
|
|
62 |
class ExtendsAccess1322 extends p.ExtendsAccess {
|
|
63 |
class N extends defaultClass { } // ERROR - cannot access 'defaultClass'
|
|
64 |
}
|
|
65 |
class ExtendsAccess1332 extends p.ExtendsAccess {
|
|
66 |
class N extends protectedClass { }
|
|
67 |
}
|
|
68 |
class ExtendsAccess1342 extends p.ExtendsAccess {
|
|
69 |
class N extends privateClass { } // ERROR - cannot access 'privateClass'
|
|
70 |
}
|
|
71 |
|
|
72 |
class ExtendsAccess1411 extends ExtendsAccess {
|
|
73 |
class N extends ExtendsAccess.publicClass { }
|
|
74 |
}
|
|
75 |
class ExtendsAccess1421 extends ExtendsAccess {
|
|
76 |
class N extends ExtendsAccess.defaultClass { }
|
|
77 |
}
|
|
78 |
class ExtendsAccess1431 extends ExtendsAccess {
|
|
79 |
class N extends ExtendsAccess.protectedClass { }
|
|
80 |
}
|
|
81 |
class ExtendsAccess1441 extends ExtendsAccess {
|
|
82 |
class N extends ExtendsAccess1441.protectedClass { }
|
|
83 |
}
|
|
84 |
class ExtendsAccess1451 extends ExtendsAccess {
|
|
85 |
class N extends ExtendsAccess.privateClass { } // ERROR - cannot access 'privateClass'
|
|
86 |
}
|
|
87 |
|
|
88 |
class ExtendsAccess1412 extends p.ExtendsAccess {
|
|
89 |
class N extends p.ExtendsAccess.publicClass { }
|
|
90 |
}
|
|
91 |
class ExtendsAccess1422 extends p.ExtendsAccess {
|
|
92 |
class N extends p.ExtendsAccess.defaultClass { } // ERROR - cannot access 'defaultClass'
|
|
93 |
}
|
|
94 |
class ExtendsAccess1432 extends p.ExtendsAccess {
|
|
95 |
class N extends p.ExtendsAccess.protectedClass { } // OK (was: should be error, see JLS 6.6.2)
|
|
96 |
}
|
|
97 |
class ExtendsAccess1442 extends p.ExtendsAccess {
|
|
98 |
class N extends ExtendsAccess1442.protectedClass { }
|
|
99 |
}
|
|
100 |
class ExtendsAccess1452 extends p.ExtendsAccess {
|
|
101 |
class N extends p.ExtendsAccess.privateClass { } // ERROR - cannot access 'privateClass'
|
|
102 |
}
|
|
103 |
|
|
104 |
class ExtendsAccess211 extends publicStaticClass { } // ERROR - 'publicStaticClass' not in scope
|
|
105 |
class ExtendsAccess212 extends defaultStaticClass { } // ERROR - 'defaultStaticClass' not in scope
|
|
106 |
class ExtendsAccess213 extends protectedStaticClass { } // ERROR - 'protectedStaticClass' not in scope
|
|
107 |
class ExtendsAccess214 extends privateStaticClass { } // ERROR - 'privateStaticClass' not in scope
|
|
108 |
|
|
109 |
class ExtendsAccess2211 extends ExtendsAccess.publicStaticClass { }
|
|
110 |
class ExtendsAccess2221 extends ExtendsAccess.defaultStaticClass { }
|
|
111 |
class ExtendsAccess2231 extends ExtendsAccess.protectedStaticClass { }
|
|
112 |
class ExtendsAccess2241 extends ExtendsAccess.privateStaticClass { } // ERROR - cannot access 'privateStaticClass'
|
|
113 |
|
|
114 |
class ExtendsAccess2212 extends p.ExtendsAccess.publicStaticClass { }
|
|
115 |
class ExtendsAccess2222 extends p.ExtendsAccess.defaultStaticClass { } // ERROR - cannot access 'defaultStaticClass'
|
|
116 |
class ExtendsAccess2232 extends p.ExtendsAccess.protectedStaticClass { }// ERROR - cannot access 'protectedStaticClass'
|
|
117 |
class ExtendsAccess2242 extends p.ExtendsAccess.privateStaticClass { } // ERROR - cannot access 'privateStaticClass'
|
|
118 |
|
|
119 |
class ExtendsAccess2311 extends ExtendsAccess {
|
|
120 |
class N extends publicStaticClass { }
|
|
121 |
}
|
|
122 |
class ExtendsAccess2321 extends ExtendsAccess {
|
|
123 |
class N extends defaultStaticClass { }
|
|
124 |
}
|
|
125 |
class ExtendsAccess2331 extends ExtendsAccess {
|
|
126 |
class N extends protectedStaticClass { }
|
|
127 |
}
|
|
128 |
class ExtendsAccess2341 extends ExtendsAccess {
|
|
129 |
class N extends privateStaticClass { } // ERROR - cannot access 'privateStaticClass'
|
|
130 |
}
|
|
131 |
|
|
132 |
class ExtendsAccess2312 extends p.ExtendsAccess {
|
|
133 |
class N extends publicStaticClass { }
|
|
134 |
}
|
|
135 |
class ExtendsAccess2322 extends p.ExtendsAccess {
|
|
136 |
class N extends defaultStaticClass { } // ERROR - cannot access 'defaultStaticClass'
|
|
137 |
}
|
|
138 |
class ExtendsAccess2332 extends p.ExtendsAccess {
|
|
139 |
class N extends protectedStaticClass { }
|
|
140 |
}
|
|
141 |
class ExtendsAccess2342 extends p.ExtendsAccess {
|
|
142 |
class N extends privateStaticClass { } // ERROR - cannot access 'privateStaticClass'
|
|
143 |
}
|
|
144 |
|
|
145 |
class ExtendsAccess2411 extends ExtendsAccess {
|
|
146 |
class N extends ExtendsAccess.publicStaticClass { }
|
|
147 |
}
|
|
148 |
class ExtendsAccess2421 extends ExtendsAccess {
|
|
149 |
class N extends ExtendsAccess.defaultStaticClass { }
|
|
150 |
}
|
|
151 |
class ExtendsAccess2431 extends ExtendsAccess {
|
|
152 |
class N extends ExtendsAccess.protectedStaticClass { } // OK (was should be error, see JLS 6.6.2)
|
|
153 |
}
|
|
154 |
class ExtendsAccess2441 extends ExtendsAccess {
|
|
155 |
class N extends ExtendsAccess2431.protectedStaticClass { }
|
|
156 |
}
|
|
157 |
class ExtendsAccess2451 extends ExtendsAccess {
|
|
158 |
class N extends ExtendsAccess.privateStaticClass { } // ERROR - cannot access 'privateStaticClass'
|
|
159 |
}
|
|
160 |
|
|
161 |
class ExtendsAccess2412 extends p.ExtendsAccess {
|
|
162 |
class N extends p.ExtendsAccess.publicStaticClass { }
|
|
163 |
}
|
|
164 |
class ExtendsAccess2422 extends p.ExtendsAccess {
|
|
165 |
class N extends p.ExtendsAccess.defaultStaticClass { } // ERROR - cannot access 'defaultStaticClass'
|
|
166 |
}
|
|
167 |
class ExtendsAccess2432 extends p.ExtendsAccess {
|
|
168 |
class N extends p.ExtendsAccess.protectedStaticClass { } // OK (was: should be error, see JLS 6.6.2)
|
|
169 |
}
|
|
170 |
class ExtendsAccess2442 extends p.ExtendsAccess {
|
|
171 |
class N extends ExtendsAccess2442.protectedStaticClass { }
|
|
172 |
}
|
|
173 |
class ExtendsAccess2452 extends p.ExtendsAccess {
|
|
174 |
class N extends p.ExtendsAccess.privateStaticClass { } // ERROR - cannot access 'privateStaticClass'
|
|
175 |
}
|
|
176 |
|
|
177 |
class ExtendsAccess311 extends ExtendsAccess implements publicInterface { } // ERROR - 'publicInterface' not in scope
|
|
178 |
class ExtendsAccess312 extends ExtendsAccess implements defaultInterface { } // ERROR - 'defaultInterface' not in scope
|
|
179 |
class ExtendsAccess313 extends ExtendsAccess implements protectedInterface { } // ERROR - 'protectedInterface' not in scope
|
|
180 |
class ExtendsAccess314 extends ExtendsAccess implements privateInterface { } // ERROR - 'privateInterface' not in scope
|
|
181 |
|
|
182 |
class ExtendsAccess3211 extends ExtendsAccess implements ExtendsAccess.publicInterface { }
|
|
183 |
class ExtendsAccess3221 extends ExtendsAccess implements ExtendsAccess.defaultInterface { }
|
|
184 |
class ExtendsAccess3231 extends ExtendsAccess implements ExtendsAccess.protectedInterface { }
|
|
185 |
class ExtendsAccess3241 extends ExtendsAccess
|
|
186 |
implements ExtendsAccess.privateInterface { } // ERROR - cannot access 'privateInterface'
|
|
187 |
|
|
188 |
class ExtendsAccess3212 extends ExtendsAccess
|
|
189 |
implements p.ExtendsAccess.publicInterface { }
|
|
190 |
class ExtendsAccess3222 extends ExtendsAccess
|
|
191 |
implements p.ExtendsAccess.defaultInterface { } // ERROR - cannot access 'defaultStaticClass'
|
|
192 |
class ExtendsAccess3232 extends ExtendsAccess
|
|
193 |
implements p.ExtendsAccess.protectedInterface { } // ERROR - cannot access 'protectedStaticClass'
|
|
194 |
class ExtendsAccess3242 extends ExtendsAccess
|
|
195 |
implements p.ExtendsAccess.privateInterface { } // ERROR - cannot access 'privateInterface'
|
|
196 |
|
|
197 |
class ExtendsAccess331 extends ExtendsAccess {
|
|
198 |
class N implements publicInterface { }
|
|
199 |
}
|
|
200 |
class ExtendsAccess3321 extends ExtendsAccess {
|
|
201 |
class N implements defaultInterface { }
|
|
202 |
}
|
|
203 |
class ExtendsAccess3331 extends ExtendsAccess {
|
|
204 |
class N implements protectedInterface { }
|
|
205 |
}
|
|
206 |
class ExtendsAccess3341 extends ExtendsAccess {
|
|
207 |
class N implements privateInterface { } // ERROR - cannot access 'privateInterface'
|
|
208 |
}
|
|
209 |
|
|
210 |
class ExtendsAccess3312 extends p.ExtendsAccess {
|
|
211 |
class N implements publicInterface { }
|
|
212 |
}
|
|
213 |
class ExtendsAccess3322 extends p.ExtendsAccess {
|
|
214 |
class N implements defaultInterface { } // ERROR - cannot access 'defaultStaticClass'
|
|
215 |
}
|
|
216 |
class ExtendsAccess3332 extends p.ExtendsAccess {
|
|
217 |
class N implements protectedInterface { }
|
|
218 |
}
|
|
219 |
class ExtendsAccess3342 extends p.ExtendsAccess {
|
|
220 |
class N implements privateInterface { } // ERROR - cannot access 'privateInterface'
|
|
221 |
}
|
|
222 |
|
|
223 |
class ExtendsAccess341 extends ExtendsAccess {
|
|
224 |
class N implements ExtendsAccess.publicInterface { }
|
|
225 |
}
|
|
226 |
class ExtendsAccess3421 extends ExtendsAccess {
|
|
227 |
class N implements ExtendsAccess.defaultInterface { }
|
|
228 |
}
|
|
229 |
class ExtendsAccess3431 extends ExtendsAccess {
|
|
230 |
class N implements ExtendsAccess.protectedInterface { } // OK (was: should be error, see JLS 6.2.2)
|
|
231 |
}
|
|
232 |
class ExtendsAccess3441 extends ExtendsAccess {
|
|
233 |
class N implements ExtendsAccess3441.protectedInterface { }
|
|
234 |
}
|
|
235 |
class ExtendsAccess3451 extends ExtendsAccess {
|
|
236 |
class N implements ExtendsAccess.privateInterface { } // ERROR - cannot access 'privateInterface'
|
|
237 |
}
|
|
238 |
|
|
239 |
class ExtendsAccess342 extends p.ExtendsAccess {
|
|
240 |
class N implements p.ExtendsAccess.publicInterface { }
|
|
241 |
}
|
|
242 |
class ExtendsAccess3422 extends p.ExtendsAccess {
|
|
243 |
class N implements p.ExtendsAccess.defaultInterface { } // ERROR - cannot access 'defaultClass'
|
|
244 |
}
|
|
245 |
class ExtendsAccess3432 extends p.ExtendsAccess {
|
|
246 |
class N implements p.ExtendsAccess.protectedInterface { } // OK (was: should be error, see JLS 6.2.2)
|
|
247 |
}
|
|
248 |
class ExtendsAccess3442 extends p.ExtendsAccess {
|
|
249 |
class N implements ExtendsAccess3442.protectedInterface { }
|
|
250 |
}
|
|
251 |
class ExtendsAccess3452 extends p.ExtendsAccess {
|
|
252 |
class N implements p.ExtendsAccess.privateInterface { } // ERROR - cannot access 'privateInterface'
|
|
253 |
}
|