test/java/rmi/testlibrary/JavaVM.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
--- 1,7 ----
/*
! * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*** 24,33 ****
--- 24,34 ----
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.StringTokenizer;
+ import java.util.concurrent.TimeUnit;
/**
* RMI regression test utility class that uses Runtime.exec to spawn a
* java process that will run a named java class.
*/
*** 171,180 ****
--- 172,200 ----
errPipe.join();
return status;
}
/**
+ * Causes the current thread to wait the subprocess to exit, if necessary,
+ * until the subprocess represented by this Process object has terminated,
+ * or the specified waiting time elapses.
+ * @param timeout the maximum time to wait
+ * @param unit the time unit of the timeout argument
+ * @return true if the JavaVM has exited and false if the waiting time
+ * elapsed before the subprocess has exited.
+ * @throws InterruptedException if the current thread is interrupted
+ * while waiting.
+ */
+ public boolean waitFor(long timeout, TimeUnit unit)
+ throws InterruptedException {
+ if (vm == null)
+ throw new IllegalStateException("can't wait for JavaVM that isn't running");
+
+ return vm.waitFor(timeout, unit);
+ }
+
+ /**
* Starts the subprocess, waits for it to exit, and returns its exit status.
*/
public int execute() throws IOException, InterruptedException {
start();
return waitFor();