Skip to content

Commit 98e7f53

Browse files
committed
8292879: com/sun/jdi/ClassUnloadEventTest.java failed due to classes not unloading
Backport-of: 6a266c4de15d04d50928b68f9b2dbb69911cff13
1 parent f378ba1 commit 98e7f53

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

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

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -101,28 +101,30 @@ private static void runDebuggee() {
101101
Class.forName(CLASS_NAME_PREFIX + index, true, loader);
102102
}
103103
} catch (Exception e) {
104-
<<<<<<< HEAD
105104
throw new RuntimeException("Failed to create Sample class", e);
106-
=======
107-
throw new RuntimeException("Failed to create Sample class");
108-
>>>>>>> 5977ce5adf85c2fb9b1dd62ed250f6d4f05a613c
109105
}
110106
}
111107
loader = null;
108+
109+
// Do a short delay to make sure that the debug agent is done processing all
110+
// ClassPrepare events. Otherwise the debug agent might still be holding on to
111+
// a reference to a class, which will prevent it from unloading during the GC.
112+
try {
113+
Thread.sleep(5000);
114+
} catch (InterruptedException e) {
115+
}
116+
112117
// Trigger class unloading
113118
ClassUnloadCommon.triggerUnloading();
114119

115-
// Short delay to make sure all ClassUnloadEvents have been sent
116-
// before VMDeathEvent is genareated.
120+
// Do a short delay to make sure all ClassUnloadEvents have been sent
121+
// before VMDeathEvent is generated.
117122
try {
118123
Thread.sleep(5000);
119124
} catch (InterruptedException e) {
120125
}
121-
<<<<<<< HEAD
122126

123127
System.out.println("Exiting debuggee");
124-
=======
125-
>>>>>>> 5977ce5adf85c2fb9b1dd62ed250f6d4f05a613c
126128
}
127129

128130
private static void runDebugger() throws Exception {
@@ -183,7 +185,6 @@ private static void runDebugger() throws Exception {
183185
eventSet.resume();
184186
}
185187

186-
<<<<<<< HEAD
187188
/* Dump debuggee output. */
188189
Process p = vm.process();
189190
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
@@ -199,8 +200,6 @@ private static void runDebugger() throws Exception {
199200
line = err.readLine();
200201
}
201202

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

0 commit comments

Comments
 (0)