From 0e501f66dfc52a0e049d4fa39c1fcd24f1f2ee4b Mon Sep 17 00:00:00 2001 From: Leonid Mesnik Date: Tue, 3 Oct 2023 15:03:21 +0000 Subject: [PATCH] 8308429: jvmti/StopThread/stopthrd007 failed with "NoClassDefFoundError: Could not initialize class jdk.internal.misc.VirtualThreads" Reviewed-by: dholmes, sspitsyn --- .../vmTestbase/nsk/jvmti/StopThread/stopthrd007.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/StopThread/stopthrd007.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/StopThread/stopthrd007.java index 61df040bcd4..fe4f346a213 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/StopThread/stopthrd007.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/StopThread/stopthrd007.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,6 +28,8 @@ import java.io.PrintStream; import nsk.share.*; import nsk.share.jvmti.*; +import java.util.concurrent.locks.LockSupport; + public class stopthrd007 extends DebugeeClass { // run test from command line @@ -66,6 +68,11 @@ public class stopthrd007 extends DebugeeClass { log = new Log(out, argHandler); timeout = argHandler.getWaitTime() * 60 * 1000; + // Unpark virtual threads to load jdk.internal.misc.VirtualThreads + // and avoid NoClassDefFoundError if ThreadDeath is happen during unlock. + Thread vt = Thread.startVirtualThread(LockSupport::park); + LockSupport.unpark(vt); + log.display("Debugee started"); startingBarrier = new Wicket(3);