diff --git a/test/jdk/ProblemList-svc-vthread.txt b/test/jdk/ProblemList-svc-vthread.txt index d559d544c82..89517b68168 100644 --- a/test/jdk/ProblemList-svc-vthread.txt +++ b/test/jdk/ProblemList-svc-vthread.txt @@ -54,8 +54,6 @@ com/sun/jdi/StepTest.java 8285422 generic-all com/sun/jdi/redefine/RedefineTest.java 8285422 generic-all com/sun/jdi/redefineMethod/RedefineTest.java 8285422 generic-all -com/sun/jdi/InvokeHangTest.java 8290200 macosx-x64,windows-x64 - #### # JDI SDE Tests # Use custom classpath diff --git a/test/jdk/com/sun/jdi/InvokeHangTest.java b/test/jdk/com/sun/jdi/InvokeHangTest.java index 2f2bd845a6b..5fc58cace5a 100644 --- a/test/jdk/com/sun/jdi/InvokeHangTest.java +++ b/test/jdk/com/sun/jdi/InvokeHangTest.java @@ -59,11 +59,23 @@ class InvokeHangTarg implements Runnable { t1.start(); t2.start(); + + try { + // The join ensures that the test completes before we exit main(). If we are using + // virtual threads, they are always daemon threads, and therefore the JVM will exit + // while they are still running (and the test has not yet completed). The join + // isn't really needed for platform threads, since by default they are not + // daemon threads, but it doesn't hurt any either. + t1.join(); + t2.join(); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } } // This is called from the debugger via invokeMethod public double invokeee() { - System.out.println("Debuggee: invokeee in thread "+Thread.currentThread().toString()); + System.out.println("Debuggee: invokeee in thread " + Thread.currentThread().toString()); Thread.yield(); return longMethod(2); } @@ -145,9 +157,9 @@ public class InvokeHangTest extends TestScaffold { List methods = ref.referenceType().methodsByName(methodName); Method method = (Method) methods.get(0); try { - System.err.println(" Debugger: Invoking in thread" + thread); + System.out.println(" Debugger: Invoking in thread " + thread); ref.invokeMethod(thread, method, new ArrayList(), ref.INVOKE_NONVIRTUAL); - System.err.println(" Debugger: Invoke done"); + System.out.println(" Debugger: Invoke done"); } catch (Exception ex) { ex.printStackTrace(); failure("failure: Exception"); @@ -191,7 +203,7 @@ public class InvokeHangTest extends TestScaffold { ThreadReference thread = event.thread(); try { StackFrame sf = thread.frame(0); - System.err.println(" Debugger: Breakpoint hit at "+sf.location()); + System.out.println(" Debugger: Breakpoint hit at " + sf.location()); doInvoke(thread, sf.thisObject(), "invokeee"); } catch (IncompatibleThreadStateException itsex) { itsex.printStackTrace(); @@ -214,7 +226,7 @@ public class InvokeHangTest extends TestScaffold { targetClass = bpe.location().declaringType(); mainThread = bpe.thread(); EventRequestManager erm = vm().eventRequestManager(); - final Thread mainThread = Thread.currentThread(); + final Thread mainTestThread = Thread.currentThread(); /* * Set event requests @@ -246,7 +258,7 @@ public class InvokeHangTest extends TestScaffold { vmDisconnected = true; // This awakens the main thread which is // waiting for a VMDisconnect. - mainThread.interrupt(); + mainTestThread.interrupt(); break; } myBkpts = bkpts;