Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions ddprof-lib/src/main/cpp/vmStructs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

#include "vmStructs.h"
#include "common.h"
#include "j9Ext.h"
#include "safeAccess.h"
#include "spinLock.h"
Expand Down Expand Up @@ -568,11 +569,16 @@ void VMStructs::initThreadBridge(JNIEnv *env) {

// Get eetop field - a bridge from Java Thread to VMThread
jclass thread_class = env->GetObjectClass(thread);
if ((_tid = env->GetFieldID(thread_class, "tid", "J")) == NULL ||
(_eetop = env->GetFieldID(thread_class, "eetop", "J")) == NULL) {
// No such field - probably not a HotSpot JVM
env->ExceptionClear();
_tid = env->GetFieldID(thread_class, "tid", "J");
_eetop = env->GetFieldID(thread_class, "eetop", "J");

if (_tid == NULL || _eetop == NULL || VM::isOpenJ9()) {
// clear any pending exceptions
TEST_LOG("J9 thread: tid=%p, eetop=%p", _tid, _eetop);
env->ExceptionClear();
// In JDK 18 and earlier the eetop will be NULL
// In JDK 19 and later the eetop is an alias to 'threadRef' value
// - https://github.com/eclipse-openj9/openj9/blob/ecbfade39c5573ed48e19961708822b5c841b2e7/runtime/oti/vmconstantpool.xml#L239
void *j9thread = J9Ext::j9thread_self();
if (j9thread != NULL) {
initTLS(j9thread);
Expand Down
Loading