diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/SelfSuspendDisablerTest/SelfSuspendDisablerTest.java b/test/hotspot/jtreg/serviceability/jvmti/vthread/SelfSuspendDisablerTest/SelfSuspendDisablerTest.java index 6a8942d4e75..f62acebd65d 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/SelfSuspendDisablerTest/SelfSuspendDisablerTest.java +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/SelfSuspendDisablerTest/SelfSuspendDisablerTest.java @@ -66,10 +66,27 @@ private static void sleep(long millis) { private static void testJvmtiThreadState(Thread thread, int expectedState) { String kindStr = thread.isVirtual()? "virtual " : "platform"; int state = getThreadState(thread); + boolean pass = true; System.out.printf("Expected %s thread state: %06X got: %06X\n", kindStr, expectedState, state); - if ((state & expectedState) != expectedState) { + if (expectedState == SUSPENDED) { + if ((state & expectedState) != expectedState) { + /* Fail if the required bits are not set. */ + pass = false; + } + /* SUSPENDED_OPTIONAL = JVMTI_THREAD_STATE_INTERRUPTED | JVMTI_THREAD_STATE_IN_NATIVE */ + int SUSPENDED_OPTIONAL = 0x200000 | 0x400000; + if ((state & ~(SUSPENDED | SUSPENDED_OPTIONAL)) != 0) { + /* Fail if any unexpected bit is set. */ + pass = false; + } + } else { + if (state != expectedState) { + pass = false; + } + } + if (!pass) { throw new RuntimeException("Test FAILED: Unexpected thread state"); } }