Skip to content

[TG-9450] Allocate reference arrays with constant size in assignments from json #5112

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
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 not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
class Util {
public static char[] chars(int count) {
char result[] = new char[count];
for (int i = 0; i < count; ++i) {
result[i] = (char)((int)'a' + i);
}
return result;
}
}

public class Test {
// static field which is initialized to a non-empty value
public static char[] staticCharArray = Util.chars(26);
// reference to the same array
public static char[] staticCharArrayRef = staticCharArray;

public static char[] charArray() {
staticCharArray[0] = staticCharArray[3];
staticCharArray[1] = 'e';
assert staticCharArray[0] == 'd';
assert staticCharArray[0] == 'A';
return staticCharArray;
}

public static char[] charArrayRef() {
staticCharArrayRef[0] = staticCharArray[3];
staticCharArray[1] = 'e';
if (staticCharArray[0] == 'A') {
assert false;
} else if (staticCharArray[0] == 'd') {
assert false;
}

return staticCharArray;
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"@type":"com.diffblue.retriever.StaticFieldMap",
"Test":{
"@type":"com.diffblue.retriever.StaticFieldMap",
"staticCharArrayRef":{
"@type":"[C",
"@ref": "id1"
},
"staticCharArray":{
"@type":"[C",
"@id": "id1",
"@items":[
"abcAefghijklmnopqrstuvwxyz"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CORE symex-driven-lazy-loading-expected-failure
Test.class
--function Test.charArrayRef --property "java::Test.charArrayRef:()[C.assertion.2" --static-values static-values.json
Generated 0 VCC[(]s[)], 0 remaining after simplification
assertion at file Test.java line 31 .*: SUCCESS
^EXIT=0$
^SIGNAL=0$
--
--
Not that the json file has been modified on purpose so that this checks
that it is actually loaded and not retrieved by execution of the Util function.
This test does not work with symex-driven-lazy-loading because this option is
not compatible with --property.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CORE symex-driven-lazy-loading-expected-failure
Test.class
--function Test.charArrayRef --property "java::Test.charArrayRef:()[C.assertion.1"
Generated 0 VCC[(]s[)], 0 remaining after simplification
assertion at file Test.java line 29 .*: SUCCESS
^EXIT=0$
^SIGNAL=0$
--
--
Note that the json file has been modified on purpose so that this checks
that it is actually loaded and not retrieved by execution of the Util function.
This test does not work with symex-driven-lazy-loading because this option is
not compatible with --property.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CORE symex-driven-lazy-loading-expected-failure
Test.class
--function Test.charArray --property "java::Test.charArray:()[C.assertion.2" --static-values static-values.json
Generated 0 VCC[(]s[)], 0 remaining after simplification
assertion at file Test.java line 21 .*: SUCCESS
^EXIT=0$
^SIGNAL=0$
--
--
Note that the json file has been modified on purpose so that this checks
that it is actually loaded and not retrieved by execution of the Util function.
This test does not work with symex-driven-lazy-loading because this option is
not compatible with --property.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CORE symex-driven-lazy-loading-expected-failure
Test.class
--function Test.charArray --property "java::Test.charArray:()[C.assertion.1"
Generated 0 VCC[(]s[)], 0 remaining after simplification
assertion at file Test.java line 20 .*: SUCCESS
^EXIT=0$
^SIGNAL=0$
--
--
Checks that constant propagation happens through static arrays.
This test does not work with symex-driven-lazy-loading because this option is
not compatible with --property.
1 change: 1 addition & 0 deletions jbmc/src/java_bytecode/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ SRC = assignments_from_json.cpp \
character_refine_preprocess.cpp \
ci_lazy_methods.cpp \
ci_lazy_methods_needed.cpp \
code_with_references.cpp \
convert_java_nondet.cpp \
create_array_with_type_intrinsic.cpp \
expr2java.cpp \
Expand Down
Loading