Skip to content

Commit 771dddb

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 9ae960f commit 771dddb

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
@@ -52,11 +52,6 @@ void ci_lazy_methods_neededt::add_all_needed_classes(
5252
const pointer_typet &pointer_type)
5353
{
5454
namespacet ns{symbol_table};
55-
const java_class_typet &underlying_type =
56-
to_java_class_type(ns.follow(pointer_type.subtype()));
57-
58-
if(underlying_type.is_abstract())
59-
return;
6055

6156
initialize_instantiated_classes_from_pointer(pointer_type, ns);
6257

jbmc/src/java_bytecode/java_bytecode_language.cpp

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

10511061
return true;

0 commit comments

Comments
 (0)