Skip to content

Commit 7901eac

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 7901eac

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

jbmc/src/java_bytecode/java_entry_point.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -210,18 +210,18 @@ 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+
irep_idt nameid = sym.symbol_expr().get_identifier();
214+
const bool is_class_model =
215+
has_suffix(id2string(nameid), "@class_model");
222216
object_factory_parameterst parameters = object_factory_parameters;
223-
if(!allow_null)
217+
if(
218+
!is_class_model &&
219+
(is_java_string_literal_id(nameid) ||
220+
is_non_null_library_global(nameid) || assume_init_pointers_not_null))
221+
{
222+
// do not allow null
224223
parameters.max_nonnull_tree_depth = 1;
224+
}
225225

226226
gen_nondet_init(
227227
sym.symbol_expr(),

0 commit comments

Comments
 (0)