Skip to content

Commit

Permalink
Merge pull request #18460 from babsingh/main2
Browse files Browse the repository at this point in the history
Make java.lang.Thread.container a known field
  • Loading branch information
gacholio authored Nov 16, 2023
2 parents e4f6968 + c528fab commit 5688e72
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
17 changes: 2 additions & 15 deletions runtime/jvmti/jvmtiHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -846,25 +846,12 @@ getVirtualThreadState(J9VMThread *currentThread, jthread thread)
break;
case JVMTI_VTHREAD_STATE_STARTED:
{
JNIEnv *env = (JNIEnv *)currentThread;
jfieldID fid = NULL;
jclass jlThread = NULL;

vm->internalVMFunctions->internalExitVMToJNI(currentThread);
jlThread = env->FindClass("java/lang/Thread");
if (NULL != jlThread) {
fid = env->GetFieldID(jlThread, "container", "Ljdk/internal/vm/ThreadContainer;");
}
if ((NULL != fid)
&& (NULL == env->GetObjectField(thread, fid))
) {
j9object_t threadContainer = J9VMJAVALANGTHREAD_CONTAINER(currentThread, vThreadObject);
if (NULL == threadContainer) {
rc = JVMTI_JAVA_LANG_THREAD_STATE_NEW;
} else {
rc = JVMTI_JAVA_LANG_THREAD_STATE_RUNNABLE;
}
vm->internalVMFunctions->internalEnterVMFromJNI(currentThread);
/* Re-fetch object to correctly set the isSuspendedInternal field. */
vThreadObject = J9_JNI_UNWRAP_REFERENCE(thread);
break;
}
case JVMTI_VTHREAD_STATE_RUNNABLE:
Expand Down
1 change: 1 addition & 0 deletions runtime/oti/vmconstantpool.xml
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-ex
<!-- Field references for Java 19 Virtual Thread. -->
<fieldref class="java/lang/Thread" name="cont" signature="Ljdk/internal/vm/Continuation;" versions="19-"/>
<fieldref class="java/lang/Thread" name="holder" signature="Ljava/lang/Thread$FieldHolder;" versions="19-"/>
<fieldref class="java/lang/Thread" name="container" signature="Ljdk/internal/vm/ThreadContainer;" versions="19-"/>
<fieldref class="java/lang/Thread$FieldHolder" name="daemon" signature="Z" versions="19-"/>
<fieldref class="java/lang/Thread$FieldHolder" name="group" signature="Ljava/lang/ThreadGroup;" versions="19-"/>
<fieldref class="java/lang/Thread$FieldHolder" name="priority" signature="I" versions="19-"/>
Expand Down

0 comments on commit 5688e72

Please sign in to comment.