@@ -42,20 +42,29 @@ SCENARIO(
42
42
{
43
43
REQUIRE (function_type.get_bool (ID_is_bridge_method));
44
44
}
45
+ THEN (" The method should be marked as declared by its class" )
46
+ {
47
+ REQUIRE (
48
+ id2string (*declaring_class (function_symbol)) ==
49
+ " java::ClassWithBridgeMethod" );
50
+ }
45
51
}
46
52
WHEN (" When parsing a non-bridge method" )
47
53
{
48
- THEN (" THe method should not be marked as a bridge method" )
49
- {
50
- const symbolt function_symbol =
51
- symbol_table.lookup_ref (method_name + " :(LClassWithBridgeMethod;)I" );
54
+ const symbolt function_symbol =
55
+ symbol_table.lookup_ref (method_name + " :(LClassWithBridgeMethod;)I" );
52
56
53
- const java_method_typet &function_type =
54
- require_type::require_java_method (function_symbol.type );
55
- THEN (" The method should be marked as a bridge method" )
56
- {
57
- REQUIRE_FALSE (function_type.get_bool (ID_is_bridge_method));
58
- }
57
+ const java_method_typet &function_type =
58
+ require_type::require_java_method (function_symbol.type );
59
+ THEN (" The method should not be marked as a bridge method." )
60
+ {
61
+ REQUIRE_FALSE (function_type.get_bool (ID_is_bridge_method));
62
+ }
63
+ THEN (" The method should be marked as declared by its class" )
64
+ {
65
+ REQUIRE (
66
+ id2string (*declaring_class (function_symbol)) ==
67
+ " java::ClassWithBridgeMethod" );
59
68
}
60
69
}
61
70
}
@@ -81,20 +90,29 @@ SCENARIO(
81
90
{
82
91
REQUIRE (to_java_method_type (function_type).get_native ());
83
92
}
93
+ THEN (" The method should be marked as declared by its class" )
94
+ {
95
+ REQUIRE (
96
+ id2string (*declaring_class (function_symbol)) ==
97
+ " java::ClassWithNativeMethod" );
98
+ }
84
99
}
85
100
WHEN (" When parsing a non-native method" )
86
101
{
87
- THEN (" THe method should not be marked as a native method" )
88
- {
89
- const symbolt function_symbol =
90
- symbol_table.lookup_ref (method_name + " :(I)Z" );
102
+ const symbolt function_symbol =
103
+ symbol_table.lookup_ref (method_name + " :(I)Z" );
91
104
92
- const java_method_typet &function_type =
93
- require_type::require_java_method (function_symbol.type );
94
- THEN (" The method should be marked as a native method" )
95
- {
96
- REQUIRE_FALSE (to_java_method_type (function_type).get_native ());
97
- }
105
+ const java_method_typet &function_type =
106
+ require_type::require_java_method (function_symbol.type );
107
+ THEN (" The method should not be marked as a native method." )
108
+ {
109
+ REQUIRE_FALSE (to_java_method_type (function_type).get_native ());
110
+ }
111
+ THEN (" The method should be marked as declared by its class" )
112
+ {
113
+ REQUIRE (
114
+ id2string (*declaring_class (function_symbol)) ==
115
+ " java::ClassWithNativeMethod" );
98
116
}
99
117
}
100
118
}
@@ -119,6 +137,12 @@ SCENARIO(
119
137
{
120
138
REQUIRE (function_type.get_is_final ());
121
139
}
140
+ THEN (" The method should be marked as declared by its class" )
141
+ {
142
+ REQUIRE (
143
+ id2string (*declaring_class (function_symbol)) ==
144
+ " java::ClassWithFinalMethod" );
145
+ }
122
146
}
123
147
WHEN (" When parsing a non-final method" )
124
148
{
@@ -130,6 +154,12 @@ SCENARIO(
130
154
{
131
155
REQUIRE (!function_type.get_is_final ());
132
156
}
157
+ THEN (" The method should be marked as declared by its class" )
158
+ {
159
+ REQUIRE (
160
+ id2string (*declaring_class (function_symbol)) ==
161
+ " java::ClassWithFinalMethod" );
162
+ }
133
163
}
134
164
WHEN (" When parsing an opaque method" )
135
165
{
@@ -169,6 +199,12 @@ SCENARIO(
169
199
{
170
200
REQUIRE (method_type.get_is_varargs ());
171
201
}
202
+ THEN (" The method should be marked as declared by its class" )
203
+ {
204
+ REQUIRE (
205
+ id2string (*declaring_class (method_symbol)) ==
206
+ " java::ClassWithVarArgsMethod" );
207
+ }
172
208
}
173
209
WHEN (" When parsing a method with constant number of arguments" )
174
210
{
@@ -180,6 +216,36 @@ SCENARIO(
180
216
{
181
217
REQUIRE_FALSE (method_type.get_is_varargs ());
182
218
}
219
+ THEN (" The method should be marked as declared by its class" )
220
+ {
221
+ REQUIRE (
222
+ id2string (*declaring_class (method_symbol)) ==
223
+ " java::ClassWithVarArgsMethod" );
224
+ }
225
+ }
226
+ }
227
+ }
228
+
229
+ SCENARIO (
230
+ " java_bytecode_convert_static_method" ,
231
+ " [core][java_bytecode][java_bytecode_convert_method]" )
232
+ {
233
+ GIVEN (" A class with a static method." )
234
+ {
235
+ const symbol_tablet symbol_table = load_java_class (
236
+ " ClassWithStaticMethod" , " ./java_bytecode/java_bytecode_convert_method" );
237
+
238
+ WHEN (" Parsing a static method." )
239
+ {
240
+ const symbolt method_symbol =
241
+ symbol_table.lookup_ref (" java::ClassWithStaticMethod.staticFunc:()I" );
242
+
243
+ THEN (" The method should be marked as declared by its class" )
244
+ {
245
+ REQUIRE (
246
+ id2string (*declaring_class (method_symbol)) ==
247
+ " java::ClassWithStaticMethod" );
248
+ }
183
249
}
184
250
}
185
251
}
0 commit comments