# HG changeset patch # User dholmes # Date 1573093122 18000 # Node ID 9a0a5e70eeb2a07014b198099538b063aa0d9ef2 # Parent dfd5196652ddf6aaa45e1f624f76f9db16806837 8233454: Test fails with assert(!is_init_completed(), "should only happen during init") after JDK-8229516 Reviewed-by: jiefu, dcubed diff -r dfd5196652dd -r 9a0a5e70eeb2 src/hotspot/share/classfile/javaClasses.cpp --- a/src/hotspot/share/classfile/javaClasses.cpp Thu Nov 07 03:01:52 2019 +0100 +++ b/src/hotspot/share/classfile/javaClasses.cpp Wed Nov 06 21:18:42 2019 -0500 @@ -1681,13 +1681,6 @@ } bool java_lang_Thread::interrupted(oop java_thread) { -#if INCLUDE_JFR - if (java_thread == NULL) { - // can happen from Jfr::on_vm_init leading to call of JavaThread::sleep - assert(!is_init_completed(), "should only happen during init"); - return false; - } -#endif return java_thread->bool_field_volatile(_interrupted_offset); } 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); }