diff -r dfd5196652dd -r 9a0a5e70eeb2 src/hotspot/share/runtime/thread.cpp --- a/src/hotspot/share/runtime/thread.cpp Thu Nov 07 03:01:52 2019 +0100 +++ b/src/hotspot/share/runtime/thread.cpp Wed Nov 06 21:18:42 2019 -0500 @@ -1741,6 +1741,16 @@ bool JavaThread::is_interrupted(bool clear_interrupted) { debug_only(check_for_dangling_thread_pointer(this);) + + if (threadObj() == NULL) { + // If there is no j.l.Thread then it is impossible to have + // been interrupted. We can find NULL during VM initialization + // or when a JNI thread is still in the process of attaching. + // In such cases this must be the current thread. + assert(this == Thread::current(), "invariant"); + return false; + } + bool interrupted = java_lang_Thread::interrupted(threadObj()); // NOTE that since there is no "lock" around the interrupt and @@ -1759,6 +1769,7 @@ // state if we are going to report that we were interrupted; otherwise // an interrupt that happens just after we read the field would be lost. if (interrupted && clear_interrupted) { + assert(this == Thread::current(), "only the current thread can clear"); java_lang_Thread::set_interrupted(threadObj(), false); osthread()->set_interrupted(false); }