Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8292880: Improve debuggee logging for com/sun/jdi/ClassUnloadEventTes…
…t.java

Backport-of: 3e187730162965981a5e6d238935e46d1015708e
  • Loading branch information
adinn committed Oct 28, 2022
1 parent 5977ce5 commit 8194120
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion test/jdk/com/sun/jdi/ClassUnloadEventTest.java
Expand Up @@ -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();
}
Expand Down Expand Up @@ -96,7 +101,11 @@ private static void runDebuggee() {
Class.forName(CLASS_NAME_PREFIX + index, true, loader);
}
} catch (Exception e) {
<<<<<<< HEAD
throw new RuntimeException("Failed to create Sample class", e);
=======
throw new RuntimeException("Failed to create Sample class");
>>>>>>> 5977ce5adf85c2fb9b1dd62ed250f6d4f05a613c
}
}
loader = null;
Expand All @@ -109,6 +118,11 @@ private static void runDebuggee() {
Thread.sleep(5000);
} catch (InterruptedException e) {
}
<<<<<<< HEAD

System.out.println("Exiting debuggee");
=======
>>>>>>> 5977ce5adf85c2fb9b1dd62ed250f6d4f05a613c
}

private static void runDebugger() throws Exception {
Expand Down Expand Up @@ -169,6 +183,24 @@ private static void runDebugger() throws Exception {
eventSet.resume();
}

<<<<<<< HEAD
/* 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();
}

=======
>>>>>>> 5977ce5adf85c2fb9b1dd62ed250f6d4f05a613c
if (unloadedSampleClasses.size() != NUM_CLASSES) {
throw new RuntimeException("Wrong number of class unload events: expected " + NUM_CLASSES + " got " + unloadedSampleClasses.size());
}
Expand All @@ -183,7 +215,11 @@ private static VirtualMachine connectAndLaunchVM() throws IOException,
LaunchingConnector launchingConnector = Bootstrap.virtualMachineManager().defaultConnector();
Map<String, Connector.Argument> arguments = launchingConnector.defaultArguments();
arguments.get("main").setValue(ClassUnloadEventTest.class.getName());
<<<<<<< HEAD
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");
=======
arguments.get("options").setValue("--add-exports java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI");
>>>>>>> 5977ce5adf85c2fb9b1dd62ed250f6d4f05a613c
return launchingConnector.launch(arguments);
}
}

1 comment on commit 8194120

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.