Skip to content

Commit 96eb10b

Browse files
author
thk123
committed
Don't instantiate abstract types when they are returned from stubs
This is less agressive than the original solution of not instantating abstract types in ci_lazy_methods at all. This is done to minimize the changes this PR introduces.
1 parent 0ad10c0 commit 96eb10b

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

jbmc/src/java_bytecode/ci_lazy_methods_needed.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@ bool ci_lazy_methods_neededt::add_needed_class(
5151
void ci_lazy_methods_neededt::add_all_needed_classes(const pointer_typet &pointer_type)
5252
{
5353
namespacet ns{symbol_table};
54-
const java_class_typet &underlying_type =
55-
to_java_class_type(ns.follow(pointer_type.subtype()));
56-
57-
if(underlying_type.is_abstract())
58-
return;
5954

6055
initialize_instantiated_classes_from_pointer(pointer_type, ns);
6156

jbmc/src/java_bytecode/java_bytecode_language.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,17 @@ bool java_bytecode_languaget::convert_single_method(
10461046
const pointer_typet *pointer_return_type =
10471047
type_try_dynamic_cast<pointer_typet>(function_type.return_type()))
10481048
{
1049-
needed_lazy_methods->add_all_needed_classes(*pointer_return_type);
1049+
// If the return type is abstract, we won't forcibly instantiate it here
1050+
// otherwise this can cause abstract methods to be explictly called
1051+
// TODO(tkiley): Arguably no abstract class should ever be added to
1052+
// TODO(tkiley): ci_lazy_methods_neededt, but this needs further
1053+
// TODO(tkiley): investigation
1054+
namespacet ns{symbol_table};
1055+
const java_class_typet &underlying_type =
1056+
to_java_class_type(ns.follow(pointer_return_type->subtype()));
1057+
1058+
if(!underlying_type.is_abstract())
1059+
needed_lazy_methods->add_all_needed_classes(*pointer_return_type);
10501060
}
10511061

10521062
return true;

0 commit comments

Comments
 (0)