@@ -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,26 +73,33 @@ 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" );
80
82
WHEN (" Parsing the InnerClasses attribute for a public inner class" )
81
83
{
82
- THEN (" The class should be marked as public" )
84
+ THEN (
85
+ " The inner class should be marked as package-private (default) because "
86
+ " its "
87
+ " containing class has stricter access " )
83
88
{
84
89
const symbolt &class_symbol = new_symbol_table.lookup_ref (
85
90
" java::InnerClassesDefault$PublicInnerClass" );
86
91
const java_class_typet java_class =
87
92
to_java_class_type (class_symbol.type );
88
93
REQUIRE_FALSE (java_class.get_is_anonymous_class ());
89
94
REQUIRE (java_class.get_is_inner_class ());
90
- REQUIRE (java_class.get_access () == ID_public );
95
+ REQUIRE (java_class.get_access () == ID_default );
91
96
}
92
97
}
93
- WHEN (" Parsing the InnerClasses attribute for a package private inner class" )
98
+ WHEN (
99
+ " Parsing the InnerClasses attribute for a package private (default) "
100
+ " inner class" )
94
101
{
95
- THEN (" The class should be marked as default" )
102
+ THEN (" The inner class should be marked as package-private ( default) " )
96
103
{
97
104
const symbolt &class_symbol = new_symbol_table.lookup_ref (
98
105
" java::InnerClassesDefault$DefaultInnerClass" );
@@ -105,20 +112,22 @@ SCENARIO(
105
112
}
106
113
WHEN (" Parsing the InnerClasses attribute for a protected inner class" )
107
114
{
108
- THEN (" The class should be marked as protected" )
115
+ THEN (
116
+ " The inner class should be marked as package-private (default) because "
117
+ " its containing class has stricter access " )
109
118
{
110
119
const symbolt &class_symbol = new_symbol_table.lookup_ref (
111
120
" java::InnerClassesDefault$ProtectedInnerClass" );
112
121
const java_class_typet java_class =
113
122
to_java_class_type (class_symbol.type );
114
123
REQUIRE_FALSE (java_class.get_is_anonymous_class ());
115
124
REQUIRE (java_class.get_is_inner_class ());
116
- REQUIRE (java_class.get_access () == ID_protected );
125
+ REQUIRE (java_class.get_access () == ID_default );
117
126
}
118
127
}
119
128
WHEN (" Parsing the InnerClasses attribute for a private inner class" )
120
129
{
121
- THEN (" The class should be marked as private" )
130
+ THEN (" The inner class should be marked as private" )
122
131
{
123
132
const symbolt &class_symbol = new_symbol_table.lookup_ref (
124
133
" java::InnerClassesDefault$PrivateInnerClass" );
@@ -141,7 +150,9 @@ SCENARIO(
141
150
" Parsing the InnerClasses attribute for a public doubly-nested inner "
142
151
" class" )
143
152
{
144
- THEN (" The class should be marked as public" )
153
+ THEN (
154
+ " The inner class should be marked as package-private (default) because "
155
+ " its containing class has stricter access " )
145
156
{
146
157
const symbolt &class_symbol = new_symbol_table.lookup_ref (
147
158
" java::InnerClassesDeeplyNested$SinglyNestedClass$"
@@ -150,14 +161,14 @@ SCENARIO(
150
161
to_java_class_type (class_symbol.type );
151
162
REQUIRE_FALSE (java_class.get_is_anonymous_class ());
152
163
REQUIRE (java_class.get_is_inner_class ());
153
- REQUIRE (java_class.get_access () == ID_public );
164
+ REQUIRE (java_class.get_access () == ID_default );
154
165
}
155
166
}
156
167
WHEN (
157
- " Parsing the InnerClasses attribute for a package private doubly-nested "
158
- " inner class" )
168
+ " Parsing the InnerClasses attribute for a package private (default) "
169
+ " doubly-nested inner class" )
159
170
{
160
- THEN (" The class should be marked as default" )
171
+ THEN (" The inner class should be marked as package-private ( default) " )
161
172
{
162
173
const symbolt &class_symbol = new_symbol_table.lookup_ref (
163
174
" java::InnerClassesDeeplyNested$SinglyNestedClass$"
@@ -170,10 +181,12 @@ SCENARIO(
170
181
}
171
182
}
172
183
WHEN (
173
- " Parsing the InnerClasses attribute for a protected doubly-nested inner "
174
- " class" )
184
+ " Parsing the InnerClasses attribute for a package private (default) "
185
+ " doubly-nested inner class " )
175
186
{
176
- THEN (" The class should be marked as protected" )
187
+ THEN (
188
+ " The inner class should be marked as package-private (default) because "
189
+ " its containing class has stricter access " )
177
190
{
178
191
const symbolt &class_symbol = new_symbol_table.lookup_ref (
179
192
" java::InnerClassesDeeplyNested$SinglyNestedClass$"
@@ -182,14 +195,14 @@ SCENARIO(
182
195
to_java_class_type (class_symbol.type );
183
196
REQUIRE_FALSE (java_class.get_is_anonymous_class ());
184
197
REQUIRE (java_class.get_is_inner_class ());
185
- REQUIRE (java_class.get_access () == ID_protected );
198
+ REQUIRE (java_class.get_access () == ID_default );
186
199
}
187
200
}
188
201
WHEN (
189
202
" Parsing the InnerClasses attribute for a private doubly-nested inner "
190
203
" class" )
191
204
{
192
- THEN (" The class should be marked as private" )
205
+ THEN (" The inner class should be marked as private " )
193
206
{
194
207
const symbolt &class_symbol = new_symbol_table.lookup_ref (
195
208
" java::InnerClassesDeeplyNested$SinglyNestedClass$"
0 commit comments