Skip to content
This repository has been archived by the owner on Dec 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #52 from babsingh/fix_SelfSuspendDisablerTest
Browse files Browse the repository at this point in the history
Check for illegal bits in SelfSuspendDisablerTest
  • Loading branch information
keithc-ca authored Dec 6, 2022
2 parents 1303c08 + d411373 commit 84975be
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
Expand Down

0 comments on commit 84975be

Please sign in to comment.