Skip to content

Commit 30a252d

Browse files
Refactor user-defined assertion translation for Java
Assertions in Java are "throw a;" statements where a is of type java.lang.AssertionError (an exception, or Throwable, to be precise). Sometimes we want to translate it into an ASSERT instruction in the goto program. Special-casing in order to handle that was scattered across multiple classes. In this commit we special-case it only once in the Java frontend and translate it into assert(false); assume(false); which is then correctly handled by later stages of the translation.
1 parent ac398d3 commit 30a252d

File tree

27 files changed

+88
-85
lines changed

27 files changed

+88
-85
lines changed

jbmc/regression/jbmc-strings/max-length/test1.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ Test.class
33
--refine-strings --verbosity 10 --string-max-input-length 499999 --function Test.checkMaxInputLength
44
^EXIT=0$
55
^SIGNAL=0$
6-
assertion.* line 9 function java::Test.checkMaxInputLength.* bytecode-index 16: SUCCESS
6+
assertion.* line 9 function java::Test.checkMaxInputLength.* bytecode-index 17: SUCCESS

jbmc/regression/jbmc-strings/max-length/test2.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ Test.class
33
--refine-strings --verbosity 10 --string-max-input-length 500000 --function Test.checkMaxInputLength
44
^EXIT=10$
55
^SIGNAL=0$
6-
assertion.* line 9 function java::Test.checkMaxInputLength.* bytecode-index 16: FAILURE
6+
assertion.* line 9 function java::Test.checkMaxInputLength.* bytecode-index 17: FAILURE

jbmc/regression/jbmc-strings/max-length/test3.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ Test.class
33
--refine-strings --verbosity 10 --string-max-length 4001 --function Test.checkMaxLength
44
^EXIT=10$
55
^SIGNAL=0$
6-
assertion.* line 25 function java::Test.checkMaxLength.* bytecode-index 26: FAILURE
6+
assertion.* line 25 function java::Test.checkMaxLength.* bytecode-index 27: FAILURE
300 Bytes
Binary file not shown.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Test
2+
{
3+
public static void main(String[] args)
4+
{
5+
AssertionError a = new AssertionError();
6+
if(false)
7+
throw a;
8+
}
9+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
Test.class
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

jbmc/regression/jbmc/exceptions23/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ test.class
44
^EXIT=10$
55
^SIGNAL=0$
66
VERIFICATION FAILED
7-
assertion at file test\.java line 9 function java::test\.main:\(\)V bytecode-index 12: FAILURE
7+
assertion at file test\.java line 9 function java::test\.main:\(\)V bytecode-index 13: FAILURE
88
--
99
^warning: ignoring
1010
--

jbmc/regression/jbmc/exceptions24/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ test.class
44
^EXIT=10$
55
^SIGNAL=0$
66
VERIFICATION FAILED
7-
assertion at file test\.java line 9 function java::test\.main:\(\)V bytecode-index 10: FAILURE
7+
assertion at file test\.java line 9 function java::test\.main:\(\)V bytecode-index 11: FAILURE
88
--
99
^warning: ignoring
1010
--

jbmc/regression/jbmc/finally1/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ test.class
33
--function test.main
44
^EXIT=10$
55
^SIGNAL=0$
6-
assertion at file test\.java line 7 function java::test\.main:\(\)V bytecode-index 9: FAILURE
6+
assertion at file test\.java line 7 function java::test\.main:\(\)V bytecode-index 10: FAILURE
77
^VERIFICATION FAILED$
88
--
99
^warning: ignoring

jbmc/regression/jbmc/finally2/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ test.class
33
--function test.main
44
^EXIT=10$
55
^SIGNAL=0$
6-
assertion at file test\.java line 8 function java::test\.main:\(\)V bytecode-index 9: FAILURE
6+
assertion at file test\.java line 8 function java::test\.main:\(\)V bytecode-index 10: FAILURE
77
^VERIFICATION FAILED$
88
--
99
^warning: ignoring

0 commit comments

Comments
 (0)