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.
This commit is contained in:
thk123 2018-06-14 10:18:34 +01:00
parent d7d5f63529
commit e95f59d86e
2 changed files with 11 additions and 6 deletions

View File

@ -52,11 +52,6 @@ void ci_lazy_methods_neededt::add_all_needed_classes(
const pointer_typet &pointer_type)
{
namespacet ns{symbol_table};
const java_class_typet &underlying_type =
to_java_class_type(ns.follow(pointer_type.subtype()));
if(underlying_type.is_abstract())
return;
initialize_instantiated_classes_from_pointer(pointer_type, ns);

View File

@ -1045,6 +1045,16 @@ bool java_bytecode_languaget::convert_single_method(
const pointer_typet *pointer_return_type =
type_try_dynamic_cast<pointer_typet>(function_type.return_type()))
{
// If the return type is abstract, we won't forcibly instantiate it here
// otherwise this can cause abstract methods to be explictly called
// TODO(tkiley): Arguably no abstract class should ever be added to
// TODO(tkiley): ci_lazy_methods_neededt, but this needs further
// TODO(tkiley): investigation
namespacet ns{symbol_table};
const java_class_typet &underlying_type =
to_java_class_type(ns.follow(pointer_return_type->subtype()));
if(!underlying_type.is_abstract())
needed_lazy_methods->add_all_needed_classes(*pointer_return_type);
}