diff --git a/test/hotspot/jtreg/ProblemList-Virtual.txt b/test/hotspot/jtreg/ProblemList-Virtual.txt index 2ae24945ee7ca..8f044dfaecafd 100644 --- a/test/hotspot/jtreg/ProblemList-Virtual.txt +++ b/test/hotspot/jtreg/ProblemList-Virtual.txt @@ -56,12 +56,6 @@ vmTestbase/nsk/jvmti/unit/GetLocalVariable/getlocal003/TestDescription.java 8300 ## Test fails because it expects to find vthreads in GetAllThreads vmTestbase/nsk/jvmti/scenarios/allocation/AP11/ap11t001/TestDescription.java 8300712 generic-all -#### -## NSK JDWP Tests failing with wrapper - -vmTestbase/nsk/jdwp/ThreadReference/ForceEarlyReturn/forceEarlyReturn002/forceEarlyReturn002.java 8286789 generic-all - - ########## ## NSK JDB Tests failing with wrapper diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdwp/ThreadReference/ForceEarlyReturn/forceEarlyReturn002/forceEarlyReturn002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdwp/ThreadReference/ForceEarlyReturn/forceEarlyReturn002/forceEarlyReturn002.java index 420dd0650536d..f8ac891b9ffb9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdwp/ThreadReference/ForceEarlyReturn/forceEarlyReturn002/forceEarlyReturn002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdwp/ThreadReference/ForceEarlyReturn/forceEarlyReturn002/forceEarlyReturn002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -55,7 +55,7 @@ * When test thread has finish execution debugger suspends thread and call command for this thread, INVALID_THREAD * error is expected, then, debugger resumes test thread and call command again, INVALID_THREAD error should * be returned in reply. - * - debuggee starts test thread which executes infinite loop in native method, debugger calls command for + * - debuggee starts test thread which executes loop in native method, debugger calls command for * this thread(without suspending) and expects THREAD_NOT_SUSPENDED error. Then, debugger suspends this thread * and calls command again, OPAQUE_FRAME error is expected. * - debugger creates ThreadStartEventRequest with suspend policy 'JDWP.SuspendPolicy.ALL' and forces debuggee start new thread. @@ -227,6 +227,9 @@ public void doTest() { // suspended thread in native, expect OPAQUE_FRAME error sendCommand(threadID, value, true, JDWP.Error.OPAQUE_FRAME); + // signal native method to exit; the thread will be actually suspended + pipe.println(forceEarlyReturn002a.COMMAND_EXIT_THREAD_IN_NATIVE); + // create request for ThreadStart event int requestID = createThreadStartEventRequest(); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdwp/ThreadReference/ForceEarlyReturn/forceEarlyReturn002/forceEarlyReturn002a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdwp/ThreadReference/ForceEarlyReturn/forceEarlyReturn002/forceEarlyReturn002a.java index 131ab11e8f8e6..c6af1dd78115d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdwp/ThreadReference/ForceEarlyReturn/forceEarlyReturn002/forceEarlyReturn002a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdwp/ThreadReference/ForceEarlyReturn/forceEarlyReturn002/forceEarlyReturn002a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -40,6 +40,8 @@ public class forceEarlyReturn002a extends AbstractJDWPDebuggee { public final static String COMMAND_STOP_THREAD_IN_NATIVE = "stopInNative"; + public final static String COMMAND_EXIT_THREAD_IN_NATIVE = "exitInNative"; + public final static String COMMAND_START_NEW_THREAD = "startNewThread"; public boolean parseCommand(String command) { @@ -49,6 +51,10 @@ public boolean parseCommand(String command) { if (command.equals(COMMAND_STOP_THREAD_IN_NATIVE)) { stopThreadInNative(); + return true; + } else if (command.equals(COMMAND_EXIT_THREAD_IN_NATIVE)) { + exitThreadInNative(); + return true; } else if (command.equals(COMMAND_START_NEW_THREAD)) { Thread thread = new Thread(new Runnable() { @@ -87,6 +93,8 @@ public void run() { private static native int nativeMethod(Object object); + private static native void exitThreadInNative(); + public static void main(String args[]) { new forceEarlyReturn002a().doTest(args); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdwp/ThreadReference/ForceEarlyReturn/forceEarlyReturn002/libforceEarlyReturn002a.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jdwp/ThreadReference/ForceEarlyReturn/forceEarlyReturn002/libforceEarlyReturn002a.cpp index 79d46c3095edb..c287de9056b1f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdwp/ThreadReference/ForceEarlyReturn/forceEarlyReturn002/libforceEarlyReturn002a.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdwp/ThreadReference/ForceEarlyReturn/forceEarlyReturn002/libforceEarlyReturn002a.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -23,23 +23,46 @@ #include "jni.h" +#if defined(_WIN32) +#include +#else +#include +#endif + +#include + extern "C" { +static std::atomic wait_in_native(true); + +static void delay(int seconds) { +#if defined(_WIN32) + Sleep(1000L * seconds); +#else + sleep(seconds); +#endif +} JNIEXPORT jint JNICALL Java_nsk_jdwp_ThreadReference_ForceEarlyReturn_forceEarlyReturn002_forceEarlyReturn002a_nativeMethod(JNIEnv *env, jobject classObject, jobject object) { - static volatile int dummy_counter = 0; // notify another thread that thread in native method jclass klass = env->GetObjectClass(object); jfieldID field = env->GetFieldID(klass, "threadInNative", "Z"); env->SetBooleanField(object, field, 1); // execute infinite loop to be sure that thread in native method - while (dummy_counter == 0) {} + while (wait_in_native) { + delay(1); + } - // Should not reach here return 0; } +JNIEXPORT void JNICALL +Java_nsk_jdwp_ThreadReference_ForceEarlyReturn_forceEarlyReturn002_forceEarlyReturn002a_exitThreadInNative(JNIEnv *env, jobject classObject) +{ + wait_in_native = false; +} + }