diff -r c97db0855565 -r 758c07667682 src/share/vm/oops/instanceKlass.cpp --- a/src/share/vm/oops/instanceKlass.cpp Tue Feb 04 17:38:01 2020 +0800 +++ b/src/share/vm/oops/instanceKlass.cpp Tue Feb 04 18:13:14 2020 +0800 @@ -294,6 +294,7 @@ set_has_unloaded_dependent(false); set_init_state(InstanceKlass::allocated); set_init_thread(NULL); + set_init_state(allocated); set_reference_type(rt); set_oop_map_cache(NULL); set_jni_ids(NULL); @@ -978,11 +979,13 @@ oop init_lock = this_oop->init_lock(); if (init_lock != NULL) { ObjectLocker ol(init_lock, THREAD); + this_oop->set_init_thread(NULL); // reset _init_thread before changing _init_state this_oop->set_init_state(state); this_oop->fence_and_clear_init_lock(); ol.notify_all(CHECK); } else { assert(init_lock != NULL, "The initialization state should never be set twice"); + this_oop->set_init_thread(NULL); // reset _init_thread before changing _init_state this_oop->set_init_state(state); } } @@ -3602,6 +3605,7 @@ bool good_state = is_shared() ? (_init_state <= state) : (_init_state < state); assert(good_state || state == allocated, "illegal state transition"); + assert(_init_thread == NULL, "should be cleared before state change"); _init_state = (u1)state; } #endif