File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44 */
55
66#include " jvmThread.h"
7-
87#include " j9/j9Ext.h"
98
109pthread_key_t JVMThread::_thread_key = pthread_key_t (-1 );
@@ -20,18 +19,18 @@ bool JVMThread::initialize() {
2019 for (int i = 0 ; i < 1024 ; i++) {
2120 if (pthread_getspecific ((pthread_key_t )i) == current_thread) {
2221 _thread_key = pthread_key_t (i);
23- return true ;
22+ break ;
2423 }
2524 }
2625
2726 assert (_tid != nullptr );
28- assert (_eetop != nullptr );
27+ assert (! VM::isHotspot () || _eetop != nullptr );
2928
3029 if (VM::isHotspot ()) {
3130 VMThread::initialize (current_thread);
3231 }
3332
34- return false ;
33+ return true ;
3534}
3635
3736void * JVMThread::current_thread_slow () {
@@ -51,12 +50,12 @@ void* JVMThread::current_thread_slow() {
5150 if ((_eetop = env->GetFieldID (thread_class, " eetop" , " J" )) == NULL ) {
5251 // No such field - probably not a HotSpot JVM
5352 env->ExceptionClear ();
54- return nullptr ;
5553 }
5654
5755 if (VM::isOpenJ9 ()) {
5856 return J9Ext::j9thread_self ();
5957 } else {
58+ assert (_eetop != nullptr );
6059 return (void *)env->GetLongField (thread, _eetop);
6160 }
6261}
Original file line number Diff line number Diff line change @@ -46,7 +46,11 @@ class JVMThread {
4646 }
4747
4848 static void * fromJavaThread (JNIEnv* env, jthread thread) {
49- return (void *)env->GetLongField (thread, _eetop);
49+ if (_eetop != nullptr ) {
50+ return (void *)env->GetLongField (thread, _eetop);
51+ } else {
52+ return nullptr ;
53+ }
5054 }
5155
5256 static inline jlong javaThreadId (JNIEnv* env, jthread thread) {
You can’t perform that action at this time.
0 commit comments