Support Runtime.halt.
authorCyrille Artho <artho@kth.se>
Sat, 17 Nov 2018 05:11:36 +0000 (16:11 +1100)
committerCyrille Artho <artho@kth.se>
Sat, 17 Nov 2018 05:11:36 +0000 (16:11 +1100)
            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.

src/peers/gov/nasa/jpf/vm/JPF_java_lang_Runtime.java
src/tests/gov/nasa/jpf/test/java/lang/RuntimeTest.java

index 8b4ea514cbe38f995185ce4b11e0ad2cb25db8b6..2ac364e217e380fbe697ddff78fb3280fc32108b 100644 (file)
@@ -62,6 +62,14 @@ public class JPF_java_lang_Runtime extends NativePeer {
   public void gc____V (MJIEnv env, int objref){
     env.gc();
   }
   public void gc____V (MJIEnv env, int objref){
     env.gc();
   }
+
+  @MJI
+  public void halt__I__V (MJIEnv env, int clsObjRef, int ret) {
+    // TODO: System.exit should start shutdown handler (once supported)
+    // and call this method (copied code should be removed in System.exit)
+    ThreadInfo ti = env.getThreadInfo();
+    env.getVM().terminateProcess(ti);
+  }
   
   @MJI
   public int availableProcessors____I (MJIEnv env, int objref){
   
   @MJI
   public int availableProcessors____I (MJIEnv env, int objref){
index e6e3d96b3cc3311d39d0b56ddf151ad4e72a6641..b03d28b12ecc8e14edc94d132b5838eb61a9674f 100644 (file)
@@ -25,6 +25,22 @@ import org.junit.Test;
 
 public class RuntimeTest extends TestJPF {
 
 
 public class RuntimeTest extends TestJPF {
 
+  @Test
+  public void testExit() {
+    if (verifyNoPropertyViolation()) {
+      System.exit(1);
+      assert(false);
+    }
+  }
+
+  @Test
+  public void testHalt() {
+    if (verifyNoPropertyViolation()) {
+      Runtime.getRuntime().halt(1);
+      assert(false);
+    }
+  }
+
   @Test
   public void testAvailableProcessors() {
 
   @Test
   public void testAvailableProcessors() {