Skip to content

Commit 1ef487f

Browse files
committed
Set declaring class for string solver implemented methods
The declaring class was not previously set for methods which are implemented by the string solver. This commit sets the declaring class for the initially empty valued method symbols. INVARIANTs are used to check that the declaring class is still set once the value of the symbol has been provided for the methods implemented by the string solver. The non violation of this INVARIANT is tested by all `strings-smoke-tests` which call such methods. For example the tests in `regression/strings-smoke-tests/java_int_to_string` will check that the INVARIANT holds for `Integer.toString`.
1 parent 18da0b1 commit 1ef487f

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

jbmc/src/java_bytecode/java_bytecode_convert_method.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ void java_bytecode_convert_method_lazy(
388388
// Not used in jbmc at present, but other codebases that use jbmc as a library
389389
// use this information.
390390
method_symbol.type.set(ID_C_abstract, m.is_abstract);
391+
set_declaring_class(method_symbol, class_symbol.name);
391392

392393
if(java_bytecode_parse_treet::find_annotation(
393394
m.annotations, "java::org.cprover.MustNotThrow"))

jbmc/src/java_bytecode/java_bytecode_language.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,7 @@ bool java_bytecode_languaget::convert_single_method(
10331033
optionalt<ci_lazy_methods_neededt> needed_lazy_methods)
10341034
{
10351035
const symbolt &symbol = symbol_table.lookup_ref(function_id);
1036+
INVARIANT(declaring_class(symbol), "Method must have a declaring class.");
10361037

10371038
// Nothing to do if body is already loaded
10381039
if(symbol.value.is_not_nil())
@@ -1060,6 +1061,8 @@ bool java_bytecode_languaget::convert_single_method(
10601061
// Add these to the needed_lazy_methods collection
10611062
notify_static_method_calls(generated_code, needed_lazy_methods);
10621063
writable_symbol.value = std::move(generated_code);
1064+
INVARIANT(
1065+
declaring_class(writable_symbol), "Method must have a declaring class.");
10631066
return false;
10641067
}
10651068
else if(

0 commit comments

Comments
 (0)