Skip to content

Commit 46849e9

Browse files
committed
Adding concurrency related methods to CProver.java
Specifically: startThread, endThread, atomicBegin, atomicEnd and getCurrentThreadID.
1 parent 784b6dd commit 46849e9

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

src/java_bytecode/java_bytecode_convert_method.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -2834,6 +2834,11 @@ void java_bytecode_convert_method(
28342834
"nondetWithNull",
28352835
"nondetWithoutNull",
28362836
"notModelled",
2837+
"atomicBegin",
2838+
"atomicEnd",
2839+
"startThread",
2840+
"endThread",
2841+
"getCurrentThreadID"
28372842
};
28382843

28392844
if(std::regex_match(

src/java_bytecode/library/src/org/cprover/CProver.java

+47
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ public final class CProver
44
{
55
public static boolean enableAssume=true;
66
public static boolean enableNondet=true;
7+
public static boolean enableConcurrency=true;
78

89
public static boolean nondetBoolean()
910
{
@@ -115,6 +116,52 @@ public static <T> T nondetWithoutNull()
115116
return null;
116117
}
117118

119+
public static void startThread(int id)
120+
{
121+
if(enableConcurrency)
122+
{
123+
throw new RuntimeException(
124+
"Cannot execute program with CProver.startThread()");
125+
}
126+
}
127+
128+
public static void endThread(int id)
129+
{
130+
if(enableConcurrency)
131+
{
132+
throw new RuntimeException(
133+
"Cannot execute program with CProver.endThread()");
134+
}
135+
}
136+
137+
public static void atomicBegin()
138+
{
139+
if(enableConcurrency)
140+
{
141+
throw new RuntimeException(
142+
"Cannot execute program with CProver.atomicBegin()");
143+
}
144+
}
145+
146+
public static void atomicEnd()
147+
{
148+
if(enableConcurrency)
149+
{
150+
throw new RuntimeException(
151+
"Cannot execute program with CProver.atomicEnd()");
152+
}
153+
}
154+
155+
public static int getCurrentThreadID()
156+
{
157+
if(enableConcurrency)
158+
{
159+
throw new RuntimeException(
160+
"Cannot execute program with CProver.getCurrentThreadID()");
161+
}
162+
return 0;
163+
}
164+
118165
public static void assume(boolean condition)
119166
{
120167
if(enableAssume && !condition)

0 commit comments

Comments
 (0)