Skip to content

Fix a bug with class identifier of nondet strings TG-1581 #1604

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added regression/jbmc-strings/instanceof/Test.class
Binary file not shown.
9 changes: 9 additions & 0 deletions regression/jbmc-strings/instanceof/Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
public class Test {

public static String check(String s) {
if (s == null)
return "null";
assert(s instanceof String);
return "non-null";
}
}
8 changes: 8 additions & 0 deletions regression/jbmc-strings/instanceof/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
Test.class
--refine-strings --string-max-length 1000 --function Test.check
^EXIT=0$
^SIGNAL=0$
assertion at file Test.java line 6 .* SUCCESS$
^VERIFICATION SUCCESSFUL$
--
2 changes: 1 addition & 1 deletion src/java_bytecode/java_object_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ codet initialize_nondet_string_struct(

// `obj` is `*expr`
const struct_typet &struct_type = to_struct_type(ns.follow(obj.type()));
const irep_idt &class_id = struct_type.get_tag();
const irep_idt &class_id = "java::" + id2string(struct_type.get_tag());

// @clsid = String and @lock = false:
const symbol_typet jlo_symbol("java::java.lang.Object");
Expand Down
3 changes: 2 additions & 1 deletion src/java_bytecode/java_root_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ void java_root_class(symbolt &class_symbol)
/// \param jlo [out] : object to initialize
/// \param root_type: type of the root class
/// \param lock: lock field
/// \param class_identifier: class identifier field
/// \param class_identifier: class identifier field, generally begins with
/// "java::" prefix.
void java_root_class_init(
struct_exprt &jlo,
const struct_typet &root_type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ SCENARIO(
"return_array = cprover_associate_length_to_array_func"
"(nondet_infinite_array, tmp_object_factory);",
"arg = { [email protected]={ .@class_identifier"
"=\"java.lang.String\", .@lock=false },"
"=\"java::java.lang.String\", .@lock=false },"
" .length=tmp_object_factory, "
".data=nondet_infinite_array };"};

Expand Down