Skip to content

Commit f378ba1

Browse files
committed
8292880: Improve debuggee logging for com/sun/jdi/ClassUnloadEventTest.java
Backport-of: 3e187730162965981a5e6d238935e46d1015708e
1 parent e501dcc commit f378ba1

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

test/jdk/com/sun/jdi/ClassUnloadEventTest.java

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,12 @@ public class ClassUnloadEventTest {
5454

5555
public static void main(String[] args) throws Exception {
5656
if (args.length == 0) {
57-
runDebuggee();
57+
try {
58+
runDebuggee();
59+
} catch (Exception e) {
60+
e.printStackTrace();
61+
throw e;
62+
}
5863
} else {
5964
runDebugger();
6065
}
@@ -96,7 +101,11 @@ private static void runDebuggee() {
96101
Class.forName(CLASS_NAME_PREFIX + index, true, loader);
97102
}
98103
} catch (Exception e) {
104+
<<<<<<< HEAD
105+
throw new RuntimeException("Failed to create Sample class", e);
106+
=======
99107
throw new RuntimeException("Failed to create Sample class");
108+
>>>>>>> 5977ce5adf85c2fb9b1dd62ed250f6d4f05a613c
100109
}
101110
}
102111
loader = null;
@@ -109,6 +118,11 @@ private static void runDebuggee() {
109118
Thread.sleep(5000);
110119
} catch (InterruptedException e) {
111120
}
121+
<<<<<<< HEAD
122+
123+
System.out.println("Exiting debuggee");
124+
=======
125+
>>>>>>> 5977ce5adf85c2fb9b1dd62ed250f6d4f05a613c
112126
}
113127

114128
private static void runDebugger() throws Exception {
@@ -169,6 +183,24 @@ private static void runDebugger() throws Exception {
169183
eventSet.resume();
170184
}
171185

186+
<<<<<<< HEAD
187+
/* Dump debuggee output. */
188+
Process p = vm.process();
189+
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
190+
BufferedReader err = new BufferedReader(new InputStreamReader(p.getErrorStream()));
191+
String line = in.readLine();
192+
while (line != null) {
193+
System.out.println("stdout: " + line);
194+
line = in.readLine();
195+
}
196+
line = err.readLine();
197+
while (line != null) {
198+
System.out.println("stderr: " + line);
199+
line = err.readLine();
200+
}
201+
202+
=======
203+
>>>>>>> 5977ce5adf85c2fb9b1dd62ed250f6d4f05a613c
172204
if (unloadedSampleClasses.size() != NUM_CLASSES) {
173205
throw new RuntimeException("Wrong number of class unload events: expected " + NUM_CLASSES + " got " + unloadedSampleClasses.size());
174206
}
@@ -183,7 +215,11 @@ private static VirtualMachine connectAndLaunchVM() throws IOException,
183215
LaunchingConnector launchingConnector = Bootstrap.virtualMachineManager().defaultConnector();
184216
Map<String, Connector.Argument> arguments = launchingConnector.defaultArguments();
185217
arguments.get("main").setValue(ClassUnloadEventTest.class.getName());
218+
<<<<<<< HEAD
219+
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");
220+
=======
186221
arguments.get("options").setValue("--add-exports java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI");
222+
>>>>>>> 5977ce5adf85c2fb9b1dd62ed250f6d4f05a613c
187223
return launchingConnector.launch(arguments);
188224
}
189225
}

0 commit comments

Comments
 (0)