Skip to content

Commit c42e4fc

Browse files
committed
Support Runtime.halt.
modified: src/peers/gov/nasa/jpf/vm/JPF_java_lang_Runtime.java: Native peers. modified: src/tests/gov/nasa/jpf/test/java/lang/RuntimeTest.java: Tests.
1 parent 0faa7fe commit c42e4fc

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/peers/gov/nasa/jpf/vm/JPF_java_lang_Runtime.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ public long freeMemory____J (MJIEnv env, int objref) {
6262
public void gc____V (MJIEnv env, int objref){
6363
env.gc();
6464
}
65+
66+
@MJI
67+
public void halt__I__V (MJIEnv env, int clsObjRef, int ret) {
68+
// TODO: System.exit should start shutdown handler (once supported)
69+
// and call this method (copied code should be removed in System.exit)
70+
ThreadInfo ti = env.getThreadInfo();
71+
env.getVM().terminateProcess(ti);
72+
}
6573

6674
@MJI
6775
public int availableProcessors____I (MJIEnv env, int objref){

src/tests/gov/nasa/jpf/test/java/lang/RuntimeTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,22 @@
2525

2626
public class RuntimeTest extends TestJPF {
2727

28+
@Test
29+
public void testExit() {
30+
if (verifyNoPropertyViolation()) {
31+
System.exit(1);
32+
assert(false);
33+
}
34+
}
35+
36+
@Test
37+
public void testHalt() {
38+
if (verifyNoPropertyViolation()) {
39+
Runtime.getRuntime().halt(1);
40+
assert(false);
41+
}
42+
}
43+
2844
@Test
2945
public void testAvailableProcessors() {
3046

0 commit comments

Comments
 (0)