test/java/rmi/testlibrary/JavaVM.java

Print this page
rev 9005 : 8007256: RMI testlibrary cleanup: remove JavaVMCallbackHandler
Reviewed-by: XXX

*** 57,69 **** File.separator + "bin" + File.separator + javaProgram; } catch (SecurityException se) { } } - public JavaVM(String classname) { - this.classname = classname; - } public JavaVM(String classname, String options, String args) { this.classname = classname; this.options = options; this.args = args; --- 57,66 ----
*** 108,126 **** */ protected static String getCodeCoverageOptions() { return TestLibrary.getExtraProperty("jcov.options",""); } - public void start(Runnable runnable) throws IOException { - if (runnable == null) { - throw new NullPointerException("Runnable cannot be null."); - } - - start(); - new JavaVMCallbackHandler(runnable).start(); - } - /** * Exec the VM as specified in this object's constructor. */ public void start() throws IOException { --- 105,114 ----
*** 174,184 **** * Waits for the subprocess to exit, joins the pipe threads to ensure that * all output is collected, and returns its exit status. */ public int waitFor() throws InterruptedException { if (vm == null) ! throw new IllegalStateException("can't wait for JavaVM that hasn't started"); int status = vm.waitFor(); outPipe.join(); errPipe.join(); return status; --- 162,172 ---- * Waits for the subprocess to exit, joins the pipe threads to ensure that * all output is collected, and returns its exit status. */ public int waitFor() throws InterruptedException { if (vm == null) ! throw new IllegalStateException("can't wait for JavaVM that isn't running"); int status = vm.waitFor(); outPipe.join(); errPipe.join(); return status;
*** 189,225 **** */ public int execute() throws IOException, InterruptedException { start(); return waitFor(); } - - /** - * Handles calling the callback. - */ - private class JavaVMCallbackHandler extends Thread { - Runnable runnable; - - JavaVMCallbackHandler(Runnable runnable) { - this.runnable = runnable; - } - - - /** - * Wait for the Process to terminate and notify the callback. - */ - @Override - public void run() { - if (vm != null) { - try { - vm.waitFor(); - } catch(InterruptedException ie) { - // Restore the interrupted status - Thread.currentThread().interrupt(); - } - } - - if (runnable != null) { - runnable.run(); - } - } - } } --- 177,182 ----