Skip to content

Commit 0bf781d

Browse files
Unit test for user specified clinit when there is no clinit
Test what happens when clinit for a class is not in the symbol table though the JSON file contains entries for this class. This used to cause map::at to throw an exception.
1 parent a88864b commit 0bf781d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

jbmc/unit/java_bytecode/java_static_initializers/java_static_initializers.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,30 @@ SCENARIO("get_user_specified_clinit_body", "[core][java_static_initializers]")
108108
REQUIRE(clinit_body == code_blockt{});
109109
}
110110
}
111+
GIVEN(
112+
"A class which has an entry in the JSON object but no clinit defined "
113+
"in the symbol table")
114+
{
115+
static_values_json["TestClass"] = [] {
116+
json_objectt entry{};
117+
entry["field_name"] = json_numbert{"42"};
118+
return entry;
119+
}();
120+
121+
const code_blockt clinit_body = get_user_specified_clinit_body(
122+
"java::TestClass",
123+
static_values_json,
124+
symbol_table,
125+
{},
126+
max_user_array_length,
127+
references,
128+
class_to_declared_symbols);
129+
130+
THEN("User provided clinit body is empty")
131+
{
132+
REQUIRE(clinit_body == code_blockt{});
133+
}
134+
}
111135
GIVEN("A class which has a static number in the provided JSON")
112136
{
113137
static_values_json["TestClass"] = [] {

0 commit comments

Comments
 (0)