8289607: Change hotspot/jtreg tests to not use Thread.suspend/resume

Reviewed-by: sspitsyn, cjplummer
This commit is contained in:
Leonid Mesnik 2022-09-23 17:44:57 +00:00
parent e2f8251490
commit 543851db92
16 changed files with 227 additions and 232 deletions

View File

@ -1666,7 +1666,7 @@ JvmtiEnvBase::resume_thread(oop thread_oop, JavaThread* java_thread, bool single
assert(single_resume || is_virtual, "ResumeAllVirtualThreads should never resume non-virtual threads");
if (java_thread->is_suspended()) {
if (!JvmtiSuspendControl::resume(java_thread)) {
return JVMTI_ERROR_INTERNAL;
return JVMTI_ERROR_THREAD_NOT_SUSPENDED;
}
}
}

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2018, 2022, 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
@ -103,8 +103,8 @@ vmTestbase_nsk_monitoring_quick = \
vmTestbase/nsk/monitoring/ThreadInfo/getLockName/getlockname001/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadInfo/getLockOwnerName/getlockownername001/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadInfo/isInNative/isinnative001/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadInfo/isSuspended/issuspended001/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadInfo/isSuspended/issuspended002/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadInfo/isSuspended/issuspended001.java \
vmTestbase/nsk/monitoring/ThreadInfo/isSuspended/issuspended002.java \
vmTestbase/nsk/monitoring/ThreadMXBean/findMonitorDeadlockedThreads/find001/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/findMonitorDeadlockedThreads/find002/TestDescription.java \
vmTestbase/nsk/monitoring/ThreadMXBean/findMonitorDeadlockedThreads/find003/TestDescription.java \

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2022, 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
@ -33,6 +33,8 @@
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:GuaranteedSafepointInterval=10 -XX:+HandshakeALot -XX:+SafepointALot HandshakeDirectTest
*/
import jvmti.JVMTIUtils;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.Semaphore;
@ -46,6 +48,26 @@ public class HandshakeDirectTest implements Runnable {
static Object[] locks = new Object[WORKING_THREADS];
static AtomicInteger handshakeCount = new AtomicInteger(0);
static void suspendThread(Thread t) {
try {
JVMTIUtils.suspendThread(t);
} catch (JVMTIUtils.JvmtiException e) {
if (e.getCode() != JVMTIUtils.JVMTI_ERROR_THREAD_NOT_ALIVE) {
throw e;
}
}
}
static void resumeThread(Thread t) {
try {
JVMTIUtils.resumeThread(t);
} catch (JVMTIUtils.JvmtiException e) {
if (e.getCode() != JVMTIUtils.JVMTI_ERROR_THREAD_NOT_ALIVE) {
throw e;
}
}
}
@Override
public void run() {
int me = Integer.parseInt(Thread.currentThread().getName());
@ -91,12 +113,12 @@ public class HandshakeDirectTest implements Runnable {
public void run() {
while (true) {
int i = ThreadLocalRandom.current().nextInt(0, WORKING_THREADS - 1);
workingThreads[i].suspend();
suspendThread(workingThreads[i]);
try {
Thread.sleep(1); // sleep for 1 ms
} catch(InterruptedException ie) {
}
workingThreads[i].resume();
resumeThread(workingThreads[i]);
}
}
};

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2022, 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
@ -30,12 +30,36 @@
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:GuaranteedSafepointInterval=1 -XX:+HandshakeALot HandshakeSuspendExitTest
*/
import jvmti.JVMTIUtils;
public class HandshakeSuspendExitTest implements Runnable {
static Thread[] _suspend_threads = new Thread[16];
static volatile boolean _exit_now = false;
static java.util.concurrent.Semaphore _sem = new java.util.concurrent.Semaphore(0);
static void suspendThread(Thread t) {
try {
JVMTIUtils.suspendThread(t);
} catch (JVMTIUtils.JvmtiException e) {
if (e.getCode() != JVMTIUtils.JVMTI_ERROR_THREAD_SUSPENDED
&& e.getCode() != JVMTIUtils.JVMTI_ERROR_THREAD_NOT_ALIVE) {
throw e;
}
}
}
static void resumeThread(Thread t) {
try {
JVMTIUtils.resumeThread(t);
} catch (JVMTIUtils.JvmtiException e) {
if (e.getCode() != JVMTIUtils.JVMTI_ERROR_THREAD_NOT_SUSPENDED
&& e.getCode() != JVMTIUtils.JVMTI_ERROR_THREAD_NOT_ALIVE) {
throw e;
}
}
}
@Override
public void run() {
_sem.release();
@ -43,14 +67,15 @@ public class HandshakeSuspendExitTest implements Runnable {
// Leave last 2 threads running.
for (int i = 0; i < _suspend_threads.length - 2; i++) {
if (Thread.currentThread() != _suspend_threads[i]) {
_suspend_threads[i].suspend();
_suspend_threads[i].resume();
suspendThread(_suspend_threads[i]);
resumeThread(_suspend_threads[i]);
}
}
}
_sem.release();
}
public static void main(String... args) throws Exception {
HandshakeSuspendExitTest test = new HandshakeSuspendExitTest();
// Fire-up suspend threads.
@ -74,10 +99,10 @@ public class HandshakeSuspendExitTest implements Runnable {
// Try to suspend them.
for (Thread thr : exit_threads) {
thr.suspend();
suspendThread(thr);
}
for (Thread thr : exit_threads) {
thr.resume();
resumeThread(thr);
}
// Start exit and join.
@ -88,7 +113,7 @@ public class HandshakeSuspendExitTest implements Runnable {
// each other at exactly the same time so they can see
// _exit_now and check in via the semaphore.
for (Thread thr : _suspend_threads) {
thr.resume();
resumeThread(thr);
}
while (_sem.tryAcquire()) {
--waiting;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2022, 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
@ -25,12 +25,14 @@
/*
* @test SuspendBlocked
* @bug 8270085
* @library /test/lib
* @library /test/lib /testlibrary
* @build SuspendBlocked
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI SuspendBlocked
*/
import jvmti.JVMTIUtils;
import jdk.test.lib.Asserts;
import jdk.test.whitebox.WhiteBox;
@ -41,10 +43,16 @@ public class SuspendBlocked {
suspend_thread.start();
WhiteBox wb = WhiteBox.getWhiteBox();
for (int i = 0; i < 100; i++) {
suspend_thread.suspend();
wb.lockAndBlock(/* suspender= */ true);
suspend_thread.resume();
Thread.sleep(1);
try {
JVMTIUtils.suspendThread(suspend_thread);
wb.lockAndBlock(/* suspender= */ true);
JVMTIUtils.resumeThread(suspend_thread);
Thread.sleep(1);
} catch (JVMTIUtils.JvmtiException e) {
if (e.getCode() != JVMTIUtils.JVMTI_ERROR_THREAD_NOT_ALIVE) {
throw e;
}
}
}
suspend_thread.join();
}

View File

@ -29,12 +29,15 @@ import java.lang.management.*;
* @comment Calling pthread_getcpuclockid() with invalid pid leads to undefined
* behavior in musl libc (see 8240187).
* @requires !vm.musl
* @library /testlibrary
* @summary Basic test of Thread and ThreadMXBean queries on a natively
* attached thread that has failed to detach before terminating.
* @comment The native code only supports POSIX so no windows testing
* @run main/othervm/native TestTerminatedThread
*/
import jvmti.JVMTIUtils;
public class TestTerminatedThread {
static native Thread createTerminatedThread();
@ -63,9 +66,9 @@ public class TestTerminatedThread {
", in state: " + t.getState());
System.out.println("Calling suspend ...");
t.suspend();
JVMTIUtils.suspendThread(t);
System.out.println("Calling resume ...");
t.resume();
JVMTIUtils.resumeThread(t);
System.out.println("Calling getStackTrace ...");
StackTraceElement[] stack = t.getStackTrace();
System.out.println(java.util.Arrays.toString(stack));

View File

@ -30,8 +30,8 @@
* VM Testbase readme:
* DESCRIPTION
* The test exercises JVMDI function GetThreadState. Java program launches
* a thread and for various thread states calls Thread.suspend()/resume()
* methods or JVMDI functions SuspendThread/ResumeThread. Then native method
* a thread and for various thread states calls
* JVMTI functions SuspendThread/ResumeThread. Then native method
* checkStatus is invoked. This method calls GetThreadState and checks if
* the returned values are correct and JVMTI_THREAD_STATE_SUSPENDED bit
* is set (or clear after resume).
@ -120,30 +120,13 @@ public class thrstat02 {
checkStatus(STATUS_MONITOR, false);
System.out.println("thrstat02.meth after checkStatus(STATUS_MONITOR,false)");
thr.suspend();
System.out.println("thrstat02.meth after thr.suspend()");
checkStatus(STATUS_MONITOR, true);
System.out.println("thrstat02.meth after checkStatus(STATUS_MONITOR,true)");
thr.resume();
System.out.println("thrstat02.meth after thr.resume()");
checkStatus(STATUS_MONITOR, false);
System.out.println("thrstat02.meth after checkStatus(STATUS_MONITOR,false)");
}
runningBarrier.await();
checkStatus(STATUS_RUNNING, false);
thr.suspend();
checkStatus(STATUS_RUNNING, true);
thr.resume();
checkStatus(STATUS_RUNNING, false);
thr.letItGo();
synchronized (endingMonitor) {
checkStatus(STATUS_WAIT, false);
thr.suspend();
checkStatus(STATUS_WAIT, true);
thr.resume();
checkStatus(STATUS_WAIT, false);
endingMonitor.val++;
endingMonitor.notifyAll();

View File

@ -25,6 +25,31 @@ package jvmti;
public class JVMTIUtils {
public static int JVMTI_ERROR_NONE = 0;
public static int JVMTI_ERROR_THREAD_NOT_SUSPENDED = 13;
public static int JVMTI_ERROR_THREAD_SUSPENDED = 14;
public static int JVMTI_ERROR_THREAD_NOT_ALIVE = 15;
public static class JvmtiException extends RuntimeException {
private int code;
public JvmtiException(int code) {
this.code = code;
}
public int getCode() {
return code;
}
@Override
public String getMessage(){
return "JVMTI ERROR: " + code;
}
}
private static native int init();
static {
@ -39,4 +64,21 @@ public class JVMTIUtils {
public static void stopThread(Thread t) {
stopThread(t, new ThreadDeath());
}
private static native int suspendThread0(Thread t);
private static native int resumeThread0(Thread t);
public static void suspendThread(Thread t) {
int err = suspendThread0(t);
if (err != JVMTI_ERROR_NONE) {
throw new JvmtiException(err);
}
}
public static void resumeThread(Thread t) {
int err = resumeThread0(t);
if (err != JVMTI_ERROR_NONE) {
throw new JvmtiException(err);
}
}
}

View File

@ -39,6 +39,7 @@ Java_jvmti_JVMTIUtils_init(JNIEnv *jni, jclass cls) {
}
jvmtiCapabilities caps;
memset(&caps, 0, sizeof (caps));
caps.can_suspend = 1;
caps.can_signal_thread = 1;
jvmtiError err = jvmti->AddCapabilities(&caps);
if (err != JVMTI_ERROR_NONE) {
@ -52,10 +53,20 @@ JNIEXPORT void JNICALL
Java_jvmti_JVMTIUtils_stopThread(JNIEnv *jni, jclass cls, jthread thread, jobject exception) {
jvmtiError err = jvmti->StopThread(thread, exception);
if (err == JVMTI_ERROR_THREAD_NOT_ALIVE) {
LOG("JVMTI_ERROR_THREAD_NOT_ALIVE happened");
LOG("JVMTI_ERROR_THREAD_NOT_ALIVE happened\n");
return;
}
check_jvmti_status(jni, err, "Error during StopThread()");
}
JNIEXPORT jint JNICALL
Java_jvmti_JVMTIUtils_suspendThread0(JNIEnv *jni, jclass cls, jthread thread) {
return jvmti->SuspendThread(thread);
}
JNIEXPORT jint JNICALL
Java_jvmti_JVMTIUtils_resumeThread0(JNIEnv *jni, jclass cls, jthread thread) {
return jvmti->ResumeThread(thread);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2022, 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
@ -133,8 +133,6 @@ public class interrupt001 {
static final String EQUALS_NOT_INTERRUPTED = "Statuses of threads are equal: not interrupted";
static final int MAX_CASE = 2;
//------------------------------------------------------ methods
private int runThis(String argv[], PrintStream out) {
@ -169,29 +167,19 @@ public class interrupt001 {
log1(" TESTING BEGINS");
for (int i = 0; i < MAX_CASE; i++) {
debuggee.sendSignal("newcheck");
try {
debuggee.receiveExpectedSignal("checkready");
} catch (Failure e) {
debuggee.quit();
throw e;
}
log1("BEGIN OF CASE #" + i);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ variable part
switch (i) {
case 0:
executeCase(i, "Thread02");
break;
case 1:
executeCase(i, "Thread12");
break;
}
debuggee.sendSignal("newcheck");
try {
debuggee.receiveExpectedSignal("checkready");
} catch (Failure e) {
debuggee.quit();
throw e;
}
log1("BEGIN OF CASE #0");
executeCase(0, "Thread02");
log1(" TESTING ENDS");
//-------------------------------------------------- test summary section

View File

@ -72,4 +72,3 @@
* -transport.address=dynamic
* -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2022, 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
@ -26,6 +26,7 @@ package nsk.jdi.ThreadReference.interrupt;
import nsk.share.jpda.*;
import nsk.share.jdi.*;
/**
* This class is used as debuggee application for the interrupt001 JDI test.
*/
@ -101,80 +102,35 @@ public class interrupt001a {
} else if (instruction.equals("newcheck")) {
switch (i) {
case 0:
synchronized (interrupt001aThread.lockingObject) {
thread2 = threadStart("Thread02");
thread3 = threadStart("Thread03");
synchronized (interrupt001aThread.lockingObject) {
thread2 = threadStart("Thread02");
thread3 = threadStart("Thread03");
pipe.println("checkready");
if (checkInterruptStatus() == FAILED) {
exitCode = FAILED;
break label0;
}
}
log1("mainThread is out of: synchronized (lockingObject)");
if (waitThreadJoin(thread2) == FAILED) {
exitCode = FAILED;
}
if (waitThreadJoin(thread3) == FAILED) {
exitCode = FAILED;
}
instruction = pipe.readln();
if (!instruction.equals("continue")) {
logErr("Unexpected instruction #1: " + instruction);
pipe.println("checkready");
if (checkInterruptStatus() == FAILED) {
exitCode = FAILED;
break label0;
}
pipe.println("docontinue");
break;
}
log1("mainThread is out of: synchronized (lockingObject)");
case 1:
synchronized (interrupt001aThread.lockingObject) {
thread2 = threadStart("Thread12");
thread3 = threadStart("Thread13");
if (waitThreadJoin(thread2) == FAILED) {
exitCode = FAILED;
}
if (waitThreadJoin(thread3) == FAILED) {
exitCode = FAILED;
}
log1("suspending Thread2");
thread2.suspend();
log1("suspending Thread3");
thread3.suspend();
log1("interrupting the Thread3");
thread3.interrupt();
pipe.println("checkready");
if (checkInterruptStatus() == FAILED) {
exitCode = FAILED;
break label0;
}
}
log1("mainThread is out of: synchronized (lockingObject)");
log1("resuming Thread2");
thread2.resume();
if (waitThreadJoin(thread2) == FAILED) {
exitCode = FAILED;
}
log1("resuming Thread3");
thread3.resume();
if (waitThreadJoin(thread3) == FAILED) {
exitCode = FAILED;
}
instruction = pipe.readln();
if (!instruction.equals("continue")) {
logErr("Unexpected instruction #2: " + instruction);
exitCode = FAILED;
break label0;
}
pipe.println("docontinue");
break;
instruction = pipe.readln();
if (!instruction.equals("continue")) {
logErr("Unexpected instruction #1: " + instruction);
exitCode = FAILED;
break label0;
}
pipe.println("docontinue");
break;
//------------------------------------------------- standard end section
}
} else {
logErr("Unexpected instruction #0: " + instruction);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2022, 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
@ -21,12 +21,42 @@
* questions.
*/
/*
* @test
*
* @summary converted from VM Testbase nsk/monitoring/ThreadInfo/isSuspended/issuspended001.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* ThreadInfo.isSuspended()
* returns correct values for a thread in different states.
* The test starts an instance of MyThread and checks that isSuspended()
* returns false for it. Then it suspends the thread and expects the method
* to return true. After that the MyThread is resumed and isSuspended() must
* return false.
* Testing of the method does not depend on the way to access metrics, so
* only one (direct access) is implemented in the test.
* COMMENT
* Fixed the bug
* 4989235 TEST: The spec is updated accoring to 4982289, 4985742
* Updated according to:
* 5024531 Fix MBeans design flaw that restricts to use JMX CompositeData
*
* @library /vmTestbase
* /test/lib
* /testlibrary
* @run main/othervm nsk.monitoring.ThreadInfo.isSuspended.issuspended001
*/
package nsk.monitoring.ThreadInfo.isSuspended;
import java.lang.management.*;
import java.io.*;
import nsk.share.*;
import jvmti.JVMTIUtils;
public class issuspended001 {
private static Wicket mainEntrance = new Wicket();
private static boolean testFailed = false;
@ -53,7 +83,7 @@ public class issuspended001 {
testFailed = true;
}
thread.suspend();
JVMTIUtils.suspendThread(thread);
info = mbean.getThreadInfo(id, Integer.MAX_VALUE);
isSuspended = info.isSuspended();
if (!isSuspended) {
@ -63,7 +93,7 @@ public class issuspended001 {
testFailed = true;
}
thread.resume();
JVMTIUtils.resumeThread(thread);
info = mbean.getThreadInfo(id, Integer.MAX_VALUE);
isSuspended = info.isSuspended();
if (isSuspended) {

View File

@ -1,51 +0,0 @@
/*
* Copyright (c) 2017, 2020, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
*
* @summary converted from VM Testbase nsk/monitoring/ThreadInfo/isSuspended/issuspended001.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* The test checks that
* ThreadInfo.isSuspended()
* returns correct values for a thread in different states.
* The test starts an instance of MyThread and checks that isSuspended()
* returns false for it. Then it suspends the thread and expects the method
* to return true. After that the MyThread is resumed and isSuspended() must
* return false.
* Testing of the method does not depend on the way to access metrics, so
* only one (direct access) is implemented in the test.
* COMMENT
* Fixed the bug
* 4989235 TEST: The spec is updated accoring to 4982289, 4985742
* Updated according to:
* 5024531 Fix MBeans design flaw that restricts to use JMX CompositeData
*
* @library /vmTestbase
* /test/lib
* @run main/othervm nsk.monitoring.ThreadInfo.isSuspended.issuspended001
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2022, 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
@ -21,12 +21,33 @@
* questions.
*/
/*
* @test
*
* @bug 8167108 8266130
* @summary converted from VM Testbase nsk/monitoring/ThreadInfo/isSuspended/issuspended002.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* Same test as issuspended001 with additional calls to
* ThreadInfo.isSuspended() as the worker thread is exiting.
* COMMENT
* Derived from nsk/monitoring/ThreadInfo/isSuspended/issuspended001.
*
* @library /vmTestbase
* /test/lib
* /testlibrary
* @run main/othervm nsk.monitoring.ThreadInfo.isSuspended.issuspended002
*/
package nsk.monitoring.ThreadInfo.isSuspended;
import java.lang.management.*;
import java.io.*;
import nsk.share.*;
import jvmti.JVMTIUtils;
public class issuspended002 {
private final static int DEF_TIME_MAX = 30; // default max # secs to test
private final static String PROG_NAME = "issuspended002";
@ -78,7 +99,7 @@ public class issuspended002 {
break;
}
thread.suspend();
JVMTIUtils.suspendThread(thread);
info = mbean.getThreadInfo(id, Integer.MAX_VALUE);
isSuspended = info.isSuspended();
if (!isSuspended) {
@ -89,7 +110,7 @@ public class issuspended002 {
break;
}
thread.resume();
JVMTIUtils.resumeThread(thread);
info = mbean.getThreadInfo(id, Integer.MAX_VALUE);
isSuspended = info.isSuspended();
if (isSuspended) {

View File

@ -1,42 +0,0 @@
/*
* Copyright (c) 2017, 2021, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
*
* @bug 8167108 8266130
* @summary converted from VM Testbase nsk/monitoring/ThreadInfo/isSuspended/issuspended002.
* VM Testbase keywords: [quick, monitoring]
* VM Testbase readme:
* DESCRIPTION
* Same test as issuspended001 with additional calls to
* ThreadInfo.isSuspended() as the worker thread is exiting.
* COMMENT
* Derived from nsk/monitoring/ThreadInfo/isSuspended/issuspended001.
*
* @library /vmTestbase
* /test/lib
* @run main/othervm nsk.monitoring.ThreadInfo.isSuspended.issuspended002
*/