Skip to content

Commit 2aa9fa5

Browse files
author
Owen
committed
Add MustNotThrow annotations to Class.java in tests
These are cut-down versions of the model for java.lang.Class. The methods that are kept are now marked MustNotThrow in the model, so that exception-handling code isn't generated in __CPROVER_initialize. We should therefore update the cut-down versions.
1 parent ade7197 commit 2aa9fa5

File tree

12 files changed

+48
-0
lines changed

12 files changed

+48
-0
lines changed
Binary file not shown.

jbmc/regression/jbmc/class-fields/java/lang/Class.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ public class Class {
44

55
public Integer field;
66

7+
@org.cprover.MustNotThrow
78
protected void cproverNondetInitialize() {
89
org.cprover.CProver.assume(field == null);
910
}
Binary file not shown.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package org.cprover;
2+
3+
public final class CProver
4+
{
5+
public static final boolean enableAssume=true;
6+
7+
public static void assume(boolean condition)
8+
{
9+
if(enableAssume)
10+
{
11+
throw new RuntimeException(
12+
"Cannot execute program with CProver.assume()");
13+
}
14+
}
15+
}
Binary file not shown.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package org.cprover;
2+
3+
/**
4+
* This can be added to methods to indicate they aren't allowed to throw
5+
* exceptions. JBMC and related tools will truncate any execution path on which
6+
* they do with an ASSUME FALSE instruction.
7+
*/
8+
public @interface MustNotThrow { }
Binary file not shown.

jbmc/regression/jbmc/class-literals/java/lang/Class.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class Class {
1212
private boolean isMemberClass;
1313
private boolean isEnum;
1414

15+
@org.cprover.MustNotThrow
1516
public void cproverInitializeClassLiteral(
1617
String name,
1718
boolean isAnnotation,
Binary file not shown.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package org.cprover;
2+
3+
public final class CProver
4+
{
5+
public static final boolean enableAssume=true;
6+
7+
public static void assume(boolean condition)
8+
{
9+
if(enableAssume)
10+
{
11+
throw new RuntimeException(
12+
"Cannot execute program with CProver.assume()");
13+
}
14+
}
15+
}
Binary file not shown.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package org.cprover;
2+
3+
/**
4+
* This can be added to methods to indicate they aren't allowed to throw
5+
* exceptions. JBMC and related tools will truncate any execution path on which
6+
* they do with an ASSUME FALSE instruction.
7+
*/
8+
public @interface MustNotThrow { }

0 commit comments

Comments
 (0)