diff --git a/runtime/jvmti/jvmtiHelpers.c b/runtime/jvmti/jvmtiHelpers.c index 6f48b1af470..48c58da6203 100644 --- a/runtime/jvmti/jvmtiHelpers.c +++ b/runtime/jvmti/jvmtiHelpers.c @@ -830,7 +830,7 @@ getVirtualThreadState(J9VMThread *currentThread, jthread thread) /* The mapping from JVMTI_VTHREAD_STATE_XXX to JVMTI_JAVA_LANG_THREAD_STATE_XXX is based * on j.l.VirtualThread.threadState(). */ - switch (vThreadState) { + switch (vThreadState & ~JVMTI_VTHREAD_STATE_SUSPENDED) { case JVMTI_VTHREAD_STATE_NEW: rc = JVMTI_JAVA_LANG_THREAD_STATE_NEW; break; @@ -858,28 +858,28 @@ getVirtualThreadState(J9VMThread *currentThread, jthread thread) break; } case JVMTI_VTHREAD_STATE_RUNNABLE: - rc = JVMTI_JAVA_LANG_THREAD_STATE_RUNNABLE; - break; - case JVMTI_VTHREAD_STATE_RUNNABLE_SUSPENDED: - rc = JVMTI_JAVA_LANG_THREAD_STATE_RUNNABLE | JVMTI_THREAD_STATE_SUSPENDED; - break; + /* Fall Through */ case JVMTI_VTHREAD_STATE_RUNNING: - rc = JVMTI_JAVA_LANG_THREAD_STATE_RUNNABLE; - break; + /* Fall Through */ case JVMTI_VTHREAD_STATE_PARKING: /* Fall Through */ + case JVMTI_VTHREAD_STATE_TIMED_PARKING: + /* Fall Through */ case JVMTI_VTHREAD_STATE_YIELDING: rc = JVMTI_JAVA_LANG_THREAD_STATE_RUNNABLE; break; case JVMTI_VTHREAD_STATE_PARKED: rc = JVMTI_JAVA_LANG_THREAD_STATE_WAITING | JVMTI_THREAD_STATE_PARKED; break; - case JVMTI_VTHREAD_STATE_PARKED_SUSPENDED: - rc = JVMTI_JAVA_LANG_THREAD_STATE_WAITING | JVMTI_THREAD_STATE_PARKED | JVMTI_THREAD_STATE_SUSPENDED; + case JVMTI_VTHREAD_STATE_TIMED_PARKED: + rc = JVMTI_JAVA_LANG_THREAD_STATE_TIMED_WAITING | JVMTI_THREAD_STATE_PARKED; break; case JVMTI_VTHREAD_STATE_PINNED: rc = JVMTI_JAVA_LANG_THREAD_STATE_WAITING; break; + case JVMTI_VTHREAD_STATE_TIMED_PINNED: + rc = JVMTI_JAVA_LANG_THREAD_STATE_TIMED_WAITING; + break; case JVMTI_VTHREAD_STATE_TERMINATED: rc = JVMTI_JAVA_LANG_THREAD_STATE_TERMINATED; break; diff --git a/runtime/oti/jvmtiInternal.h b/runtime/oti/jvmtiInternal.h index ecbeb914fb0..4c10a0187b1 100644 --- a/runtime/oti/jvmtiInternal.h +++ b/runtime/oti/jvmtiInternal.h @@ -579,11 +579,12 @@ typedef struct jvmtiGcp_translation { #define JVMTI_VTHREAD_STATE_PARKING 4 #define JVMTI_VTHREAD_STATE_PARKED 5 #define JVMTI_VTHREAD_STATE_PINNED 6 -#define JVMTI_VTHREAD_STATE_YIELDING 7 +#define JVMTI_VTHREAD_STATE_TIMED_PARKING 7 +#define JVMTI_VTHREAD_STATE_TIMED_PARKED 8 +#define JVMTI_VTHREAD_STATE_TIMED_PINNED 9 +#define JVMTI_VTHREAD_STATE_YIELDING 10 #define JVMTI_VTHREAD_STATE_TERMINATED 99 #define JVMTI_VTHREAD_STATE_SUSPENDED (1 << 8) -#define JVMTI_VTHREAD_STATE_RUNNABLE_SUSPENDED (JVMTI_VTHREAD_STATE_RUNNABLE | JVMTI_VTHREAD_STATE_SUSPENDED) -#define JVMTI_VTHREAD_STATE_PARKED_SUSPENDED (JVMTI_VTHREAD_STATE_PARKED | JVMTI_VTHREAD_STATE_SUSPENDED) #endif /* JAVA_SPEC_VERSION >= 19 */ /* The brace mismatches in the macros below are due to the usage pattern: diff --git a/test/functional/Java21andUp/src/org/openj9/test/jep425/VirtualThreadTests.java b/test/functional/Java21andUp/src/org/openj9/test/jep425/VirtualThreadTests.java index 70ebf2ddfe0..8f57b73427e 100644 --- a/test/functional/Java21andUp/src/org/openj9/test/jep425/VirtualThreadTests.java +++ b/test/functional/Java21andUp/src/org/openj9/test/jep425/VirtualThreadTests.java @@ -270,11 +270,12 @@ public void test_verifyJVMTIMacros() { final int JVMTI_VTHREAD_STATE_PARKING = 4; final int JVMTI_VTHREAD_STATE_PARKED = 5; final int JVMTI_VTHREAD_STATE_PINNED = 6; - final int JVMTI_VTHREAD_STATE_YIELDING = 7; + final int JVMTI_VTHREAD_STATE_TIMED_PARKING = 7; + final int JVMTI_VTHREAD_STATE_TIMED_PARKED = 8; + final int JVMTI_VTHREAD_STATE_TIMED_PINNED = 9; + final int JVMTI_VTHREAD_STATE_YIELDING = 10; final int JVMTI_VTHREAD_STATE_TERMINATED = 99; final int JVMTI_VTHREAD_STATE_SUSPENDED = (1 << 8); - final int JVMTI_VTHREAD_STATE_RUNNABLE_SUSPENDED = (JVMTI_VTHREAD_STATE_RUNNABLE | JVMTI_VTHREAD_STATE_SUSPENDED); - final int JVMTI_VTHREAD_STATE_PARKED_SUSPENDED = (JVMTI_VTHREAD_STATE_PARKED | JVMTI_VTHREAD_STATE_SUSPENDED); int value = 0; @@ -316,6 +317,21 @@ public void test_verifyJVMTIMacros() { Assert.fail("JVMTI_VTHREAD_STATE_PINNED (" + JVMTI_VTHREAD_STATE_PINNED + ") does not match VirtualThread.PINNED (" + value + ")"); } + value = readVirtualThreadStates(vthreadCls, "TIMED_PARKING"); + if (JVMTI_VTHREAD_STATE_TIMED_PARKING != value) { + Assert.fail("JVMTI_VTHREAD_STATE_TIMED_PARKING (" + JVMTI_VTHREAD_STATE_TIMED_PARKING + ") does not match VirtualThread.TIMED_PARKING (" + value + ")"); + } + + value = readVirtualThreadStates(vthreadCls, "TIMED_PARKED"); + if (JVMTI_VTHREAD_STATE_TIMED_PARKED != value) { + Assert.fail("JVMTI_VTHREAD_STATE_TIMED_PARKED (" + JVMTI_VTHREAD_STATE_TIMED_PARKED + ") does not match VirtualThread.TIMED_PARKED (" + value + ")"); + } + + value = readVirtualThreadStates(vthreadCls, "TIMED_PINNED"); + if (JVMTI_VTHREAD_STATE_TIMED_PINNED != value) { + Assert.fail("JVMTI_VTHREAD_STATE_TIMED_PINNED (" + JVMTI_VTHREAD_STATE_TIMED_PINNED + ") does not match VirtualThread.TIMED_PINNED (" + value + ")"); + } + value = readVirtualThreadStates(vthreadCls, "YIELDING"); if (JVMTI_VTHREAD_STATE_YIELDING != value) { Assert.fail("JVMTI_VTHREAD_STATE_YIELDING (" + JVMTI_VTHREAD_STATE_YIELDING + ") does not match VirtualThread.YIELDING (" + value + ")"); @@ -330,16 +346,6 @@ public void test_verifyJVMTIMacros() { if (JVMTI_VTHREAD_STATE_SUSPENDED != value) { Assert.fail("JVMTI_VTHREAD_STATE_SUSPENDED (" + JVMTI_VTHREAD_STATE_SUSPENDED + ") does not match VirtualThread.SUSPENDED (" + value + ")"); } - - value = readVirtualThreadStates(vthreadCls, "RUNNABLE_SUSPENDED"); - if (JVMTI_VTHREAD_STATE_RUNNABLE_SUSPENDED != value) { - Assert.fail("JVMTI_VTHREAD_STATE_RUNNABLE_SUSPENDED (" + JVMTI_VTHREAD_STATE_RUNNABLE_SUSPENDED + ") does not match VirtualThread.RUNNABLE_SUSPENDED (" + value + ")"); - } - - value = readVirtualThreadStates(vthreadCls, "PARKED_SUSPENDED"); - if (JVMTI_VTHREAD_STATE_PARKED_SUSPENDED != value) { - Assert.fail("JVMTI_VTHREAD_STATE_PARKED_SUSPENDED (" + JVMTI_VTHREAD_STATE_PARKED_SUSPENDED + ") does not match VirtualThread.PARKED_SUSPENDED (" + value + ")"); - } } catch (Exception e) { Assert.fail("Unexpected exception occured : " + e.getMessage() , e); }