@@ -295,6 +295,83 @@ SCENARIO(
295
295
}
296
296
}
297
297
298
+ GIVEN (
299
+ " Some class files where the outer class is more restrictive than the first "
300
+ " inner class" )
301
+ {
302
+ const symbol_tablet &new_symbol_table = load_java_class (
303
+ " OuterClassMostRestrictiveDeeplyNested" ,
304
+ " ./java_bytecode/java_bytecode_parser" );
305
+ WHEN (
306
+ " Parsing the InnerClasses attribute for a public doubly-nested inner "
307
+ " class" )
308
+ {
309
+ THEN (
310
+ " The inner class should be marked as default (package-private) because "
311
+ " one of its containing classes has stricter access " )
312
+ {
313
+ const symbolt &class_symbol = new_symbol_table.lookup_ref (
314
+ " java::OuterClassMostRestrictiveDeeplyNested$SinglyNestedPublicClass$"
315
+ " PublicDoublyNestedInnerClass" );
316
+ const java_class_typet java_class =
317
+ to_java_class_type (class_symbol.type );
318
+ REQUIRE_FALSE (java_class.get_is_anonymous_class ());
319
+ REQUIRE (java_class.get_is_inner_class ());
320
+ REQUIRE (java_class.get_access () == ID_default);
321
+ }
322
+ }
323
+ WHEN (
324
+ " Parsing the InnerClasses attribute for a package private doubly-nested "
325
+ " inner class" )
326
+ {
327
+ THEN (
328
+ " The inner class should be marked as default (package-private) because "
329
+ " one of its containing classes has stricter access " )
330
+ {
331
+ const symbolt &class_symbol = new_symbol_table.lookup_ref (
332
+ " java::OuterClassMostRestrictiveDeeplyNested$SinglyNestedPublicClass$"
333
+ " DefaultDoublyNestedInnerClass" );
334
+ const java_class_typet java_class =
335
+ to_java_class_type (class_symbol.type );
336
+ REQUIRE_FALSE (java_class.get_is_anonymous_class ());
337
+ REQUIRE (java_class.get_is_inner_class ());
338
+ REQUIRE (java_class.get_access () == ID_default);
339
+ }
340
+ }
341
+ WHEN (
342
+ " Parsing the InnerClasses attribute for a protected doubly-nested inner "
343
+ " class" )
344
+ {
345
+ THEN (" The inner class should be marked as default (package-private)" )
346
+ {
347
+ const symbolt &class_symbol = new_symbol_table.lookup_ref (
348
+ " java::OuterClassMostRestrictiveDeeplyNested$SinglyNestedPublicClass$"
349
+ " ProtectedDoublyNestedInnerClass" );
350
+ const java_class_typet java_class =
351
+ to_java_class_type (class_symbol.type );
352
+ REQUIRE_FALSE (java_class.get_is_anonymous_class ());
353
+ REQUIRE (java_class.get_is_inner_class ());
354
+ REQUIRE (java_class.get_access () == ID_default);
355
+ }
356
+ }
357
+ WHEN (
358
+ " Parsing the InnerClasses attribute for a private doubly-nested inner "
359
+ " class" )
360
+ {
361
+ THEN (" The inner class should be marked as private" )
362
+ {
363
+ const symbolt &class_symbol = new_symbol_table.lookup_ref (
364
+ " java::OuterClassMostRestrictiveDeeplyNested$SinglyNestedPublicClass$"
365
+ " PrivateDoublyNestedInnerClass" );
366
+ const java_class_typet java_class =
367
+ to_java_class_type (class_symbol.type );
368
+ REQUIRE_FALSE (java_class.get_is_anonymous_class ());
369
+ REQUIRE (java_class.get_is_inner_class ());
370
+ REQUIRE (java_class.get_access () == ID_private);
371
+ }
372
+ }
373
+ }
374
+
298
375
GIVEN (
299
376
" Some package-private class files in the class path with anonymous classes" )
300
377
{
0 commit comments