8292880: Improve debuggee logging for com/sun/jdi/ClassUnloadEventTest.java
Reviewed-by: amenkov, kevinw
This commit is contained in:
parent
909e1edb18
commit
3e18773016
@ -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 @@ public class ClassUnloadEventTest {
|
||||
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 @@ public class ClassUnloadEventTest {
|
||||
Thread.sleep(5000);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
|
||||
System.out.println("Exiting debuggee");
|
||||
}
|
||||
|
||||
private static void runDebugger() throws Exception {
|
||||
@ -169,6 +176,21 @@ public class ClassUnloadEventTest {
|
||||
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 @@ public class ClassUnloadEventTest {
|
||||
LaunchingConnector launchingConnector = Bootstrap.virtualMachineManager().defaultConnector();
|
||||
Map<String, Connector.Argument> 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);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user