--- old/src/hotspot/share/classfile/classLoaderData.cpp 2018-06-22 17:12:39.459292459 -0400 +++ new/src/hotspot/share/classfile/classLoaderData.cpp 2018-06-22 17:12:37.947944956 -0400 @@ -109,10 +109,9 @@ // it will be available for error messages, logging, JFR, etc. The name // and klass are available after the class_loader oop is no longer alive, // during unloading. -void ClassLoaderData::initialize_name_and_klass(Handle class_loader) { +void ClassLoaderData::initialize_name(Handle class_loader) { Thread* THREAD = Thread::current(); ResourceMark rm(THREAD); - _class_loader_klass = class_loader->klass(); // Obtain the class loader's name. If the class loader's name was not // explicitly set during construction, the CLD's _name field will be null. @@ -161,6 +160,10 @@ _class_loader = _handles.add(h_class_loader()); } + if (!h_class_loader.is_null()) { + _class_loader_klass = h_class_loader->klass(); + } + if (!is_anonymous) { // The holder is initialized later for anonymous classes, and before calling anything // that call class_loader(). @@ -951,9 +954,10 @@ const char* ClassLoaderData::loader_name_and_id() const { if (_class_loader_klass == NULL) { return "'" BOOTSTRAP_LOADER_NAME "'"; - } else { - assert(_name_and_id != NULL, "encountered a class loader null name and id"); + } else if (_name_and_id != NULL) { return _name_and_id->as_C_string(); + } else { + return _class_loader_klass->external_name(); } } @@ -1072,7 +1076,7 @@ // Initialize name and class after the loader data is added to the CLDG // because adding the Symbol for the name might safepoint. if (loader.not_null()) { - loader_data->initialize_name_and_klass(loader); + loader_data->initialize_name(loader); } return loader_data; } --- old/src/hotspot/share/classfile/classLoaderData.hpp 2018-06-22 17:12:51.029373174 -0400 +++ new/src/hotspot/share/classfile/classLoaderData.hpp 2018-06-22 17:12:49.583354283 -0400 @@ -305,7 +305,7 @@ Dictionary* create_dictionary(); - void initialize_name_and_klass(Handle class_loader); + void initialize_name(Handle class_loader); public: // GC interface. void clear_claimed() { _claimed = 0; }