Skip to content

Commit 92afefe

Browse files
committed
java_class_typet: record method descriptor
Along with the basename already stored on class_typet::methodt, this means we can compare two Java methods for name and descriptor compatibility without having to parse the composite method identifier.
1 parent 6473900 commit 92afefe

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

jbmc/src/java_bytecode/java_bytecode_convert_method.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -410,14 +410,13 @@ void java_bytecode_convert_method_lazy(
410410

411411
if(!m.is_static)
412412
{
413-
class_typet::methodt new_method;
414-
new_method.set_name(method_symbol.name);
413+
java_class_typet::methodt new_method{method_symbol.name, method_type};
415414
new_method.set_base_name(method_symbol.base_name);
416415
new_method.set_pretty_name(method_symbol.pretty_name);
417416
new_method.set_access(member_type.get_access());
418-
new_method.type() = method_symbol.type;
417+
new_method.set_descriptor(m.descriptor);
419418

420-
to_class_type(class_symbol.type)
419+
to_java_class_type(class_symbol.type)
421420
.methods()
422421
.emplace_back(std::move(new_method));
423422
}

jbmc/src/java_bytecode/java_types.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,18 @@ class java_class_typet:public class_typet
283283
{
284284
set(ID_is_native_method, is_native);
285285
}
286+
287+
/// Gets the method's descriptor -- the mangled form of its type
288+
const irep_idt &get_descriptor() const
289+
{
290+
return get(ID_object_descriptor);
291+
}
292+
293+
/// Sets the method's descriptor -- the mangled form of its type
294+
void set_descriptor(const irep_idt &id)
295+
{
296+
set(ID_object_descriptor, id);
297+
}
286298
};
287299

288300
using methodst = std::vector<methodt>;

0 commit comments

Comments
 (0)