Skip to content

Commit 20645c9

Browse files
author
thk123
committed
Add classes to needed classes for parameters and returns for opaque calls
Use gather all fields when setting up the return of an opaque method This can be considered an input to the function under test, so therefore we need to set it up in the same way.
1 parent 9d42bc8 commit 20645c9

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

jbmc/src/java_bytecode/ci_lazy_methods.cpp

-11
Original file line numberDiff line numberDiff line change
@@ -177,17 +177,6 @@ bool ci_lazy_methodst::operator()(
177177
symbol_table);
178178
}
179179

180-
// cproverNondetInitialize has to be force-loaded for mocks to return valid
181-
// objects (objects which satisfy invariants specified in the
182-
// cproverNondetInitialize method)
183-
for(const auto &class_name : instantiated_classes)
184-
{
185-
const irep_idt cprover_validate =
186-
id2string(class_name) + ".cproverNondetInitialize:()V";
187-
if(symbol_table.symbols.count(cprover_validate))
188-
methods_already_populated.insert(cprover_validate);
189-
}
190-
191180
// Remove symbols for methods that were declared but never used:
192181
symbol_tablet keep_symbols;
193182
// Manually keep @inflight_exception, as it is unused at this stage

jbmc/src/java_bytecode/java_bytecode_language.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,16 @@ bool java_bytecode_languaget::convert_single_method(
10381038
return false;
10391039
}
10401040

1041+
// The return of an opaque function is a source of an otherwise invisible
1042+
// instantiation, so here we ensure we've loaded the appropriate classes.
1043+
const code_typet function_type = to_code_type(symbol.type);
1044+
if(
1045+
const pointer_typet *pointer_return_type =
1046+
type_try_dynamic_cast<pointer_typet>(function_type.return_type()))
1047+
{
1048+
needed_lazy_methods->add_all_needed_classes(*pointer_return_type);
1049+
}
1050+
10411051
return true;
10421052
}
10431053

0 commit comments

Comments
 (0)