< prev index next >
src/hotspot/share/classfile/classLoaderData.cpp
Print this page
@@ -107,14 +107,13 @@
// Obtain and set the class loader's name within the ClassLoaderData so
// 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.
oop cl_name = java_lang_ClassLoader::name(class_loader());
if (cl_name != NULL) {
@@ -159,10 +158,14 @@
if (!h_class_loader.is_null()) {
_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().
initialize_holder(h_class_loader);
@@ -949,13 +952,14 @@
// If the defining loader has no name then <qualified-class-name> @<id>
// If built-in loader, then omit '@<id>' as there is only one instance.
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();
}
}
void ClassLoaderData::print_value_on(outputStream* out) const {
if (!is_unloading() && class_loader() != NULL) {
@@ -1070,11 +1074,11 @@
ClassLoaderData* ClassLoaderDataGraph::add(Handle loader, bool is_anonymous) {
ClassLoaderData* loader_data = add_to_graph(loader, is_anonymous);
// 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;
}
void ClassLoaderDataGraph::oops_do(OopClosure* f, bool must_claim) {
< prev index next >