Skip to content

Commit 7d0195a

Browse files
Fix allow-null initialization logic for class models
@class_model.name must be non-null whereas @class_mode.table must be null. These constraints are enforced in the models library. The generic nondet- initialisation must use allow-null for these constraints to take effect correctly.
1 parent 774060b commit 7d0195a

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

jbmc/src/java_bytecode/java_entry_point.cpp

+7-10
Original file line numberDiff line numberDiff line change
@@ -210,17 +210,14 @@ static void java_static_lifetime_init(
210210
}
211211
else if(sym.value.is_nil() && sym.type!=empty_typet())
212212
{
213-
bool allow_null=!assume_init_pointers_not_null;
214-
if(allow_null)
215-
{
216-
irep_idt nameid=sym.symbol_expr().get_identifier();
217-
if(allow_null && is_java_string_literal_id(nameid))
218-
allow_null=false;
219-
if(allow_null && is_non_null_library_global(nameid))
220-
allow_null = false;
221-
}
213+
const bool is_class_model =
214+
has_suffix(id2string(sym.name), "@class_model");
215+
const bool not_allow_null = is_java_string_literal_id(sym.name) ||
216+
is_non_null_library_global(sym.name) ||
217+
assume_init_pointers_not_null;
218+
222219
object_factory_parameterst parameters = object_factory_parameters;
223-
if(!allow_null)
220+
if(not_allow_null && !is_class_model)
224221
parameters.max_nonnull_tree_depth = 1;
225222

226223
gen_nondet_init(

0 commit comments

Comments
 (0)