6563318: RMI data sanitization
Reviewed-by: ahgross, hawtin, mchung, smarks
diff --git a/test/java/rmi/testlibrary/JavaVM.java b/test/java/rmi/testlibrary/JavaVM.java
index 62be87d..d7b94bf 100644
--- a/test/java/rmi/testlibrary/JavaVM.java
+++ b/test/java/rmi/testlibrary/JavaVM.java
@@ -133,6 +133,14 @@
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.
@@ -235,4 +243,35 @@
protected Process getVM() {
return vm;
}
+
+ /**
+ * 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();
+ }
+ }
+ }
}