Skip to content

Commit 3fddf20

Browse files
Merge pull request #691 from reuk/java-nondet-new-pass
Add support for explicit nondet in java code
2 parents 58f3c44 + ff72ddc commit 3fddf20

File tree

90 files changed

+1205
-5
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+1205
-5
lines changed

regression/cbmc-java/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,16 @@ clean:
2323
find -name '*.out' -execdir $(RM) '{}' \;
2424
find -name '*.gb' -execdir $(RM) '{}' \;
2525
$(RM) tests.log
26+
27+
%.class: %.java ../../src/org.cprover.jar
28+
javac -g -cp ../../src/org.cprover.jar:. $<
29+
30+
nondet_java_files := $(shell find . -name "Nondet*.java")
31+
nondet_class_files := $(patsubst %.java, %.class, $(nondet_java_files))
32+
33+
.PHONY: nondet-class-files
34+
nondet-class-files: $(nondet_class_files)
35+
36+
.PHONY: clean-nondet-class-files
37+
clean-nondet-class-files:
38+
-rm $(nondet_class_files)
722 Bytes
Binary file not shown.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import org.cprover.CProver;
2+
3+
class NondetArray
4+
{
5+
void main()
6+
{
7+
Object[] obj = CProver.nondetWithoutNull();
8+
assert obj != null;
9+
}
10+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
NondetArray.class
3+
--function NondetArray.main
4+
^VERIFICATION SUCCESSFUL$
5+
--
6+
^warning: ignoring
Binary file not shown.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import org.cprover.CProver;
2+
3+
class NondetArray2
4+
{
5+
void main()
6+
{
7+
Integer[] ints = CProver.nondetWithoutNull();
8+
9+
int num = 0;
10+
for (Integer i : ints) {
11+
num *= i.intValue();
12+
}
13+
assert num == 0;
14+
}
15+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
NondetArray2.class
3+
--function NondetArray2.main --unwind 5
4+
^VERIFICATION SUCCESSFUL$
5+
--
6+
^warning: ignoring
Binary file not shown.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import org.cprover.CProver;
2+
3+
class NondetArray3
4+
{
5+
void main()
6+
{
7+
Integer[] ints = CProver.nondetWithoutNull();
8+
assert ints != null;
9+
10+
int num = 0;
11+
for (Integer i : ints) {
12+
num *= i.intValue();
13+
}
14+
assert num == 0;
15+
}
16+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
NondetArray3.class
3+
--function NondetArray3.main --unwind 5
4+
^VERIFICATION SUCCESSFUL$
5+
--
6+
^warning: ignoring
Binary file not shown.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import org.cprover.CProver;
2+
3+
class NondetArray4
4+
{
5+
void main()
6+
{
7+
int a = 1;
8+
int b = 2;
9+
int c = 3;
10+
11+
Integer[] ints = CProver.nondetWithoutNull();
12+
assert ints != null;
13+
}
14+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
NondetArray4.class
3+
--function NondetArray4.main
4+
^VERIFICATION SUCCESSFUL$
5+
--
6+
^warning: ignoring
Binary file not shown.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import org.cprover.CProver;
2+
3+
class NondetAssume1
4+
{
5+
void main()
6+
{
7+
int x = CProver.nondetInt();
8+
CProver.assume(x == 1);
9+
assert x == 1;
10+
}
11+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
NondetAssume1.class
3+
--function NondetAssume1.main
4+
^VERIFICATION SUCCESSFUL$
5+
--
6+
^warning: ignoring
256 Bytes
Binary file not shown.
258 Bytes
Binary file not shown.
258 Bytes
Binary file not shown.
Binary file not shown.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import org.cprover.CProver;
2+
3+
class A { int x; }
4+
5+
class B { A a; }
6+
7+
class C { B b; }
8+
9+
class NondetAssume2
10+
{
11+
void main()
12+
{
13+
C c = CProver.nondetWithNull();
14+
CProver.assume(c != null);
15+
assert c != null;
16+
}
17+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
NondetAssume2.class
3+
--function NondetAssume2.main
4+
^VERIFICATION SUCCESSFUL$
5+
--
6+
^warning: ignoring
Binary file not shown.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import org.cprover.CProver;
2+
3+
class NondetBoolean
4+
{
5+
static void main()
6+
{
7+
boolean x = CProver.nondetBoolean();
8+
assert x == false;
9+
}
10+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
NondetBoolean.class
3+
--function NondetBoolean.main
4+
^VERIFICATION FAILED$
5+
--
6+
^warning: ignoring
657 Bytes
Binary file not shown.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import org.cprover.CProver;
2+
3+
class NondetByte
4+
{
5+
static void main()
6+
{
7+
byte x = CProver.nondetByte();
8+
assert x == 0;
9+
}
10+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
NondetByte.class
3+
--function NondetByte.main
4+
^VERIFICATION FAILED$
5+
--
6+
^warning: ignoring
Binary file not shown.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import org.cprover.CProver;
2+
3+
class NondetCastToObject
4+
{
5+
void main()
6+
{
7+
Object o = CProver.nondetWithNull();
8+
CProver.assume(o != null);
9+
assert o != null;
10+
}
11+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
NondetCastToObject.class
3+
--function NondetCastToObject.main
4+
^VERIFICATION SUCCESSFUL$
5+
--
6+
^warning: ignoring
657 Bytes
Binary file not shown.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import org.cprover.CProver;
2+
3+
class NondetChar
4+
{
5+
static void main()
6+
{
7+
char x = CProver.nondetChar();
8+
assert x == '\0';
9+
}
10+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
NondetChar.class
3+
--function NondetChar.main
4+
^VERIFICATION FAILED$
5+
--
6+
^warning: ignoring
265 Bytes
Binary file not shown.
Binary file not shown.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import org.cprover.CProver;
2+
3+
class A
4+
{
5+
int a;
6+
}
7+
8+
class NondetDirectFromMethod
9+
{
10+
A methodReturningA()
11+
{
12+
return CProver.nondetWithoutNull();
13+
}
14+
15+
void main()
16+
{
17+
assert methodReturningA() != null;
18+
}
19+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
NondetDirectFromMethod.class
3+
--function NondetDirectFromMethod.main
4+
^VERIFICATION SUCCESSFUL$
5+
--
6+
^warning: ignoring
Binary file not shown.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import org.cprover.CProver;
2+
3+
class NondetDouble
4+
{
5+
static void main()
6+
{
7+
double x = CProver.nondetDouble();
8+
assert x == 0;
9+
}
10+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
NondetDouble.class
3+
--function NondetDouble.main
4+
^VERIFICATION FAILED$
5+
--
6+
^warning: ignoring
663 Bytes
Binary file not shown.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import org.cprover.CProver;
2+
3+
class NondetFloat
4+
{
5+
static void main()
6+
{
7+
float x = CProver.nondetFloat();
8+
assert x == 0;
9+
}
10+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
NondetFloat.class
3+
--function NondetFloat.main
4+
^VERIFICATION FAILED$
5+
--
6+
^warning: ignoring
287 Bytes
Binary file not shown.
263 Bytes
Binary file not shown.
263 Bytes
Binary file not shown.
Binary file not shown.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import org.cprover.CProver;
2+
3+
class A
4+
{
5+
int[] ints = new int[10];
6+
}
7+
8+
class B
9+
{
10+
A a;
11+
}
12+
13+
class C
14+
{
15+
B b;
16+
}
17+
18+
class NondetGenericArray
19+
{
20+
static void main()
21+
{
22+
C c = CProver.nondetWithNull();
23+
CProver.assume(c != null);
24+
CProver.assume(c.b != null);
25+
CProver.assume(c.b.a != null);
26+
CProver.assume(c.b.a.ints != null);
27+
assert c.b.a != null;
28+
assert c.b.a.ints != null;
29+
}
30+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
NondetGenericArray.class
3+
--function NondetGenericArray.main
4+
^VERIFICATION SUCCESSFUL$
5+
--
6+
^warning: ignoring
249 Bytes
Binary file not shown.
267 Bytes
Binary file not shown.
267 Bytes
Binary file not shown.
Binary file not shown.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import org.cprover.CProver;
2+
3+
class A
4+
{
5+
}
6+
7+
class B
8+
{
9+
A a;
10+
}
11+
12+
class C
13+
{
14+
B b;
15+
}
16+
17+
class NondetGenericRecursive
18+
{
19+
static void main()
20+
{
21+
C c = CProver.nondetWithNull();
22+
assert c == null;
23+
}
24+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
NondetGenericRecursive.class
3+
--function NondetGenericRecursive.main
4+
^VERIFICATION FAILED$
5+
--
6+
^warning: ignoring
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import org.cprover.CProver;
2+
3+
class A
4+
{
5+
}
6+
7+
class B
8+
{
9+
A a;
10+
}
11+
12+
class C
13+
{
14+
B b;
15+
}
16+
17+
class NondetGenericRecursive2
18+
{
19+
static void main()
20+
{
21+
C c = CProver.nondetWithNull();
22+
CProver.assume(c != null);
23+
CProver.assume(c.b != null);
24+
CProver.assume(c.b.a != null);
25+
assert c.b.a != null;
26+
}
27+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
NondetGenericRecursive2.class
3+
--function NondetGenericRecursive2.main
4+
^VERIFICATION SUCCESSFUL$
5+
--
6+
^warning: ignoring
264 Bytes
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)