--- old/src/hotspot/share/classfile/classLoaderData.cpp 2018-09-27 22:39:01.749314405 -0400 +++ new/src/hotspot/share/classfile/classLoaderData.cpp 2018-09-27 22:39:00.341233972 -0400 @@ -345,6 +345,11 @@ for (Klass* k = OrderAccess::load_acquire(&_klasses); k != NULL; k = k->next_link()) { // Do not filter ArrayKlass oops here... if (k->is_array_klass() || (k->is_instance_klass() && InstanceKlass::cast(k)->is_loaded())) { +#ifdef ASSERT + oop m = k->java_mirror(); + assert(m != NULL, "NULL mirror"); + assert(m->is_a(SystemDictionary::Class_klass()), "invalid mirror"); +#endif klass_closure->do_klass(k); } } --- old/src/hotspot/share/oops/instanceKlass.cpp 2018-09-27 22:39:06.189568057 -0400 +++ new/src/hotspot/share/oops/instanceKlass.cpp 2018-09-27 22:39:04.773487166 -0400 @@ -2304,6 +2304,9 @@ if (is_linked()) { unlink_class(); } + + _init_state = allocated; + { MutexLocker ml(Compile_lock); init_implementor(); @@ -2350,6 +2353,10 @@ } void InstanceKlass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS) { + // SystemDictionary::add_to_hierarchy() sets the init_state to loaded + // before the InstanceKlass is added to the the SystemDictionary. Make + // sure the current state is