@@ -22,7 +22,7 @@ SCENARIO(
22
22
load_java_class (" InnerClasses" , " ./java_bytecode/java_bytecode_parser" );
23
23
WHEN (" Parsing the InnerClasses attribute for a public inner class" )
24
24
{
25
- THEN (" The class should be marked as public" )
25
+ THEN (" The inner class should be marked as public" )
26
26
{
27
27
const symbolt &class_symbol =
28
28
new_symbol_table.lookup_ref (" java::InnerClasses$PublicInnerClass" );
@@ -35,7 +35,7 @@ SCENARIO(
35
35
}
36
36
WHEN (" Parsing the InnerClasses attribute for a package private inner class" )
37
37
{
38
- THEN (" The class should be marked as default" )
38
+ THEN (" The inner class should be marked as default" )
39
39
{
40
40
const symbolt &class_symbol =
41
41
new_symbol_table.lookup_ref (" java::InnerClasses$DefaultInnerClass" );
@@ -48,7 +48,7 @@ SCENARIO(
48
48
}
49
49
WHEN (" Parsing the InnerClasses attribute for a protected inner class" )
50
50
{
51
- THEN (" The class should be marked as protected" )
51
+ THEN (" The inner class should be marked as protected" )
52
52
{
53
53
const symbolt &class_symbol =
54
54
new_symbol_table.lookup_ref (" java::InnerClasses$ProtectedInnerClass" );
@@ -61,7 +61,7 @@ SCENARIO(
61
61
}
62
62
WHEN (" Parsing the InnerClasses attribute for a private inner class" )
63
63
{
64
- THEN (" The class should be marked as private" )
64
+ THEN (" The inner class should be marked as private" )
65
65
{
66
66
const symbolt &class_symbol =
67
67
new_symbol_table.lookup_ref (" java::InnerClasses$PrivateInnerClass" );
@@ -73,7 +73,9 @@ SCENARIO(
73
73
}
74
74
}
75
75
}
76
- GIVEN (" Some package-private class files in the class path with inner classes" )
76
+ GIVEN (
77
+ " Some package-private (default) class files in the class path with inner "
78
+ " classes" )
77
79
{
78
80
const symbol_tablet &new_symbol_table = load_java_class (
79
81
" InnerClassesDefault" , " ./java_bytecode/java_bytecode_parser" );
@@ -90,9 +92,11 @@ SCENARIO(
90
92
REQUIRE (java_class.get_access () == ID_public);
91
93
}
92
94
}
93
- WHEN (" Parsing the InnerClasses attribute for a package private inner class" )
95
+ WHEN (
96
+ " Parsing the InnerClasses attribute for a package private (default) "
97
+ " inner class" )
94
98
{
95
- THEN (" The class should be marked as default" )
99
+ THEN (" The inner class should be marked as package-private ( default) " )
96
100
{
97
101
const symbolt &class_symbol = new_symbol_table.lookup_ref (
98
102
" java::InnerClassesDefault$DefaultInnerClass" );
@@ -118,7 +122,7 @@ SCENARIO(
118
122
}
119
123
WHEN (" Parsing the InnerClasses attribute for a private inner class" )
120
124
{
121
- THEN (" The class should be marked as private" )
125
+ THEN (" The inner class should be marked as private" )
122
126
{
123
127
const symbolt &class_symbol = new_symbol_table.lookup_ref (
124
128
" java::InnerClassesDefault$PrivateInnerClass" );
@@ -154,10 +158,10 @@ SCENARIO(
154
158
}
155
159
}
156
160
WHEN (
157
- " Parsing the InnerClasses attribute for a package private doubly-nested "
158
- " inner class" )
161
+ " Parsing the InnerClasses attribute for a package private (default) "
162
+ " doubly-nested inner class" )
159
163
{
160
- THEN (" The class should be marked as default" )
164
+ THEN (" The inner class should be marked as package-private ( default) " )
161
165
{
162
166
const symbolt &class_symbol = new_symbol_table.lookup_ref (
163
167
" java::InnerClassesDeeplyNested$SinglyNestedClass$"
@@ -170,10 +174,10 @@ SCENARIO(
170
174
}
171
175
}
172
176
WHEN (
173
- " Parsing the InnerClasses attribute for a protected doubly-nested inner "
174
- " class" )
177
+ " Parsing the InnerClasses attribute for a package private (default) "
178
+ " doubly-nested inner class " )
175
179
{
176
- THEN (" The class should be marked as protected" )
180
+ THEN (" The inner class should be marked as protected" )
177
181
{
178
182
const symbolt &class_symbol = new_symbol_table.lookup_ref (
179
183
" java::InnerClassesDeeplyNested$SinglyNestedClass$"
@@ -189,7 +193,7 @@ SCENARIO(
189
193
" Parsing the InnerClasses attribute for a private doubly-nested inner "
190
194
" class" )
191
195
{
192
- THEN (" The class should be marked as private" )
196
+ THEN (" The inner class should be marked as private " )
193
197
{
194
198
const symbolt &class_symbol = new_symbol_table.lookup_ref (
195
199
" java::InnerClassesDeeplyNested$SinglyNestedClass$"
@@ -203,6 +207,162 @@ SCENARIO(
203
207
}
204
208
}
205
209
210
+ GIVEN (
211
+ " Some package-private class files in the class path with private deeply"
212
+ " nested inner classes" )
213
+ {
214
+ const symbol_tablet &new_symbol_table = load_java_class (
215
+ " InnerPrivateClassesDeeplyNested" ,
216
+ " ./java_bytecode/java_bytecode_parser" );
217
+ WHEN (
218
+ " Parsing the InnerClasses attribute for a public doubly-nested inner "
219
+ " class" )
220
+ {
221
+ THEN (
222
+ " The inner class should be marked as private because its containing "
223
+ " class has stricter access " )
224
+ {
225
+ const symbolt &class_symbol = new_symbol_table.lookup_ref (
226
+ " java::InnerPrivateClassesDeeplyNested$SinglyNestedPrivateClass$"
227
+ " PublicDoublyNestedInnerClass" );
228
+ const java_class_typet java_class =
229
+ to_java_class_type (class_symbol.type );
230
+ REQUIRE_FALSE (java_class.get_is_anonymous_class ());
231
+ REQUIRE (java_class.get_is_inner_class ());
232
+ REQUIRE (java_class.get_access () == ID_private);
233
+ }
234
+ }
235
+ WHEN (
236
+ " Parsing the InnerClasses attribute for a package private doubly-nested "
237
+ " inner class" )
238
+ {
239
+ THEN (
240
+ " The inner class should be marked as private because its containing "
241
+ " class has stricter access " )
242
+ {
243
+ const symbolt &class_symbol = new_symbol_table.lookup_ref (
244
+ " java::InnerPrivateClassesDeeplyNested$SinglyNestedPrivateClass$"
245
+ " DefaultDoublyNestedInnerClass" );
246
+ const java_class_typet java_class =
247
+ to_java_class_type (class_symbol.type );
248
+ REQUIRE_FALSE (java_class.get_is_anonymous_class ());
249
+ REQUIRE (java_class.get_is_inner_class ());
250
+ REQUIRE (java_class.get_access () == ID_private);
251
+ }
252
+ }
253
+ WHEN (
254
+ " Parsing the InnerClasses attribute for a protected doubly-nested inner "
255
+ " class" )
256
+ {
257
+ THEN (
258
+ " The inner class should be marked as private because its containing "
259
+ " class has stricter access " )
260
+ {
261
+ const symbolt &class_symbol = new_symbol_table.lookup_ref (
262
+ " java::InnerPrivateClassesDeeplyNested$SinglyNestedPrivateClass$"
263
+ " ProtectedDoublyNestedInnerClass" );
264
+ const java_class_typet java_class =
265
+ to_java_class_type (class_symbol.type );
266
+ REQUIRE_FALSE (java_class.get_is_anonymous_class ());
267
+ REQUIRE (java_class.get_is_inner_class ());
268
+ REQUIRE (java_class.get_access () == ID_private);
269
+ }
270
+ }
271
+ WHEN (
272
+ " Parsing the InnerClasses attribute for a private doubly-nested inner "
273
+ " class" )
274
+ {
275
+ THEN (" The inner class should be marked as private " )
276
+ {
277
+ const symbolt &class_symbol = new_symbol_table.lookup_ref (
278
+ " java::InnerPrivateClassesDeeplyNested$SinglyNestedPrivateClass$"
279
+ " PrivateDoublyNestedInnerClass" );
280
+ const java_class_typet java_class =
281
+ to_java_class_type (class_symbol.type );
282
+ REQUIRE_FALSE (java_class.get_is_anonymous_class ());
283
+ REQUIRE (java_class.get_is_inner_class ());
284
+ REQUIRE (java_class.get_access () == ID_private);
285
+ }
286
+ }
287
+ }
288
+
289
+ GIVEN (
290
+ " Some class files where the outer class is more restrictive than the first "
291
+ " inner class" )
292
+ {
293
+ const symbol_tablet &new_symbol_table = load_java_class (
294
+ " OuterClassMostRestrictiveDeeplyNested" ,
295
+ " ./java_bytecode/java_bytecode_parser" );
296
+ WHEN (
297
+ " Parsing the InnerClasses attribute for a public doubly-nested inner "
298
+ " class" )
299
+ {
300
+ THEN (
301
+ " The inner class should be marked as default (package-private) because "
302
+ " one of its containing classes has stricter access " )
303
+ {
304
+ const symbolt &class_symbol = new_symbol_table.lookup_ref (
305
+ " java::OuterClassMostRestrictiveDeeplyNested$SinglyNestedPublicClass$"
306
+ " PublicDoublyNestedInnerClass" );
307
+ const java_class_typet java_class =
308
+ to_java_class_type (class_symbol.type );
309
+ REQUIRE_FALSE (java_class.get_is_anonymous_class ());
310
+ REQUIRE (java_class.get_is_inner_class ());
311
+ REQUIRE (java_class.get_access () == ID_default);
312
+ }
313
+ }
314
+ WHEN (
315
+ " Parsing the InnerClasses attribute for a package private doubly-nested "
316
+ " inner class" )
317
+ {
318
+ THEN (
319
+ " The inner class should be marked as default (package-private) because "
320
+ " one of its containing classes has stricter access " )
321
+ {
322
+ const symbolt &class_symbol = new_symbol_table.lookup_ref (
323
+ " java::OuterClassMostRestrictiveDeeplyNested$SinglyNestedPublicClass$"
324
+ " DefaultDoublyNestedInnerClass" );
325
+ const java_class_typet java_class =
326
+ to_java_class_type (class_symbol.type );
327
+ REQUIRE_FALSE (java_class.get_is_anonymous_class ());
328
+ REQUIRE (java_class.get_is_inner_class ());
329
+ REQUIRE (java_class.get_access () == ID_default);
330
+ }
331
+ }
332
+ WHEN (
333
+ " Parsing the InnerClasses attribute for a protected doubly-nested inner "
334
+ " class" )
335
+ {
336
+ THEN (" The inner class should be marked as default (package-private)" )
337
+ {
338
+ const symbolt &class_symbol = new_symbol_table.lookup_ref (
339
+ " java::OuterClassMostRestrictiveDeeplyNested$SinglyNestedPublicClass$"
340
+ " ProtectedDoublyNestedInnerClass" );
341
+ const java_class_typet java_class =
342
+ to_java_class_type (class_symbol.type );
343
+ REQUIRE_FALSE (java_class.get_is_anonymous_class ());
344
+ REQUIRE (java_class.get_is_inner_class ());
345
+ REQUIRE (java_class.get_access () == ID_default);
346
+ }
347
+ }
348
+ WHEN (
349
+ " Parsing the InnerClasses attribute for a private doubly-nested inner "
350
+ " class" )
351
+ {
352
+ THEN (" The inner class should be marked as private" )
353
+ {
354
+ const symbolt &class_symbol = new_symbol_table.lookup_ref (
355
+ " java::OuterClassMostRestrictiveDeeplyNested$SinglyNestedPublicClass$"
356
+ " PrivateDoublyNestedInnerClass" );
357
+ const java_class_typet java_class =
358
+ to_java_class_type (class_symbol.type );
359
+ REQUIRE_FALSE (java_class.get_is_anonymous_class ());
360
+ REQUIRE (java_class.get_is_inner_class ());
361
+ REQUIRE (java_class.get_access () == ID_private);
362
+ }
363
+ }
364
+ }
365
+
206
366
GIVEN (
207
367
" Some package-private class files in the class path with anonymous classes" )
208
368
{
0 commit comments