diff --git a/test/jdk/com/sun/jdi/ClassUnloadEventTest.java b/test/jdk/com/sun/jdi/ClassUnloadEventTest.java index 360240b578a7b..7518175805523 100644 --- a/test/jdk/com/sun/jdi/ClassUnloadEventTest.java +++ b/test/jdk/com/sun/jdi/ClassUnloadEventTest.java @@ -54,7 +54,12 @@ public class ClassUnloadEventTest { public static void main(String[] args) throws Exception { if (args.length == 0) { - runDebuggee(); + try { + runDebuggee(); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } } else { runDebugger(); } @@ -96,7 +101,7 @@ private static void runDebuggee() { Class.forName(CLASS_NAME_PREFIX + index, true, loader); } } catch (Exception e) { - throw new RuntimeException("Failed to create Sample class"); + throw new RuntimeException("Failed to create Sample class", e); } } loader = null; @@ -109,6 +114,8 @@ private static void runDebuggee() { Thread.sleep(5000); } catch (InterruptedException e) { } + + System.out.println("Exiting debuggee"); } private static void runDebugger() throws Exception { @@ -169,6 +176,21 @@ private static void runDebugger() throws Exception { eventSet.resume(); } + /* Dump debuggee output. */ + Process p = vm.process(); + BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream())); + BufferedReader err = new BufferedReader(new InputStreamReader(p.getErrorStream())); + String line = in.readLine(); + while (line != null) { + System.out.println("stdout: " + line); + line = in.readLine(); + } + line = err.readLine(); + while (line != null) { + System.out.println("stderr: " + line); + line = err.readLine(); + } + if (unloadedSampleClasses.size() != NUM_CLASSES) { throw new RuntimeException("Wrong number of class unload events: expected " + NUM_CLASSES + " got " + unloadedSampleClasses.size()); } @@ -183,7 +205,7 @@ private static VirtualMachine connectAndLaunchVM() throws IOException, LaunchingConnector launchingConnector = Bootstrap.virtualMachineManager().defaultConnector(); Map arguments = launchingConnector.defaultArguments(); arguments.get("main").setValue(ClassUnloadEventTest.class.getName()); - arguments.get("options").setValue("--add-exports java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI"); + arguments.get("options").setValue("--add-exports java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xlog:class+unload=info -Xlog:gc"); return launchingConnector.launch(arguments); } }