Skip to content

Commit edc75fa

Browse files
Merge pull request diffblue#1604 from romainbrenguier/bugfix/string-nondet-init#TG1581
Fix a bug with class identifier of nondet strings TG-1581
2 parents 3d16d36 + ac2a599 commit edc75fa

File tree

6 files changed

+21
-3
lines changed

6 files changed

+21
-3
lines changed
602 Bytes
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
public class Test {
2+
3+
public static String check(String s) {
4+
if (s == null)
5+
return "null";
6+
assert(s instanceof String);
7+
return "non-null";
8+
}
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
Test.class
3+
--refine-strings --string-max-length 1000 --function Test.check
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
assertion at file Test.java line 6 .* SUCCESS$
7+
^VERIFICATION SUCCESSFUL$
8+
--

src/java_bytecode/java_object_factory.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ codet initialize_nondet_string_struct(
554554

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

559559
// @clsid = String and @lock = false:
560560
const symbol_typet jlo_symbol("java::java.lang.Object");

src/java_bytecode/java_root_class.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ void java_root_class(symbolt &class_symbol)
5757
/// \param jlo [out] : object to initialize
5858
/// \param root_type: type of the root class
5959
/// \param lock: lock field
60-
/// \param class_identifier: class identifier field
60+
/// \param class_identifier: class identifier field, generally begins with
61+
/// "java::" prefix.
6162
void java_root_class_init(
6263
struct_exprt &jlo,
6364
const struct_typet &root_type,

unit/java_bytecode/java_object_factory/gen_nondet_string_init.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ SCENARIO(
7979
"return_array = cprover_associate_length_to_array_func"
8080
"(nondet_infinite_array, tmp_object_factory);",
8181
"arg = { [email protected]={ .@class_identifier"
82-
"=\"java.lang.String\", .@lock=false },"
82+
"=\"java::java.lang.String\", .@lock=false },"
8383
" .length=tmp_object_factory, "
8484
".data=nondet_infinite_array };"};
8585

0 commit comments

Comments
 (0)