Skip to content

Commit adc9fd4

Browse files
committed
Java frontend: clean up unused clinit symbols
Previously clinit wrappers that had been generated but never actually called would remain in the GOTO program as empty, uncalled functions. Now they are cleaned up in the same way as unused user functions.
1 parent ef08ae2 commit adc9fd4

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

src/java_bytecode/ci_lazy_methods.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,16 @@ ci_lazy_methodst::ci_lazy_methodst(
3636
java_class_loadert &java_class_loader,
3737
const std::vector<irep_idt> &extra_needed_classes,
3838
const select_pointer_typet &pointer_type_selector,
39-
message_handlert &message_handler)
39+
message_handlert &message_handler,
40+
const synthetic_methods_mapt &synthetic_methods)
4041
: messaget(message_handler),
4142
main_class(main_class),
4243
main_jar_classes(main_jar_classes),
4344
lazy_methods_extra_entry_points(lazy_methods_extra_entry_points),
4445
java_class_loader(java_class_loader),
4546
extra_needed_classes(extra_needed_classes),
46-
pointer_type_selector(pointer_type_selector)
47+
pointer_type_selector(pointer_type_selector),
48+
synthetic_methods(synthetic_methods)
4749
{
4850
// build the class hierarchy
4951
class_hierarchy(symbol_table);
@@ -196,7 +198,8 @@ bool ci_lazy_methodst::operator()(
196198
// Don't keep functions that belong to this language that we haven't
197199
// converted above
198200
if(
199-
method_bytecode.contains_method(sym.first) &&
201+
(method_bytecode.contains_method(sym.first) ||
202+
synthetic_methods.count(sym.first)) &&
200203
!methods_already_populated.count(sym.first))
201204
{
202205
continue;

src/java_bytecode/ci_lazy_methods.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <java_bytecode/java_class_loader.h>
2424
#include <java_bytecode/ci_lazy_methods_needed.h>
2525
#include <java_bytecode/select_pointer_type.h>
26+
#include <java_bytecode/synthetic_methods_map.h>
2627

2728
class java_string_library_preprocesst;
2829

@@ -99,7 +100,8 @@ class ci_lazy_methodst:public messaget
99100
java_class_loadert &java_class_loader,
100101
const std::vector<irep_idt> &extra_needed_classes,
101102
const select_pointer_typet &pointer_type_selector,
102-
message_handlert &message_handler);
103+
message_handlert &message_handler,
104+
const synthetic_methods_mapt &synthetic_methods);
103105

104106
// not const since messaget
105107
bool operator()(
@@ -164,6 +166,7 @@ class ci_lazy_methodst:public messaget
164166
java_class_loadert &java_class_loader;
165167
const std::vector<irep_idt> &extra_needed_classes;
166168
const select_pointer_typet &pointer_type_selector;
169+
const synthetic_methods_mapt &synthetic_methods;
167170
};
168171

169172
#endif // CPROVER_JAVA_BYTECODE_GATHER_METHODS_LAZILY_H

src/java_bytecode/java_bytecode_language.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,8 @@ bool java_bytecode_languaget::do_ci_lazy_method_conversion(
688688
java_class_loader,
689689
java_load_classes,
690690
get_pointer_type_selector(),
691-
get_message_handler());
691+
get_message_handler(),
692+
synthetic_methods);
692693

693694
return method_gather(symbol_table, method_bytecode, method_converter);
694695
}

0 commit comments

Comments
 (0)