< prev index next >

src/hotspot/share/classfile/classLoaderData.cpp

Print this page

        

*** 107,120 **** // 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) { 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) { --- 107,119 ---- // 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(Handle class_loader) { Thread* THREAD = Thread::current(); ResourceMark rm(THREAD); // 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) {
*** 157,166 **** --- 156,166 ---- _metaspace_lock(new Mutex(Monitor::leaf+1, "Metaspace allocation lock", true, Monitor::_safepoint_check_never)) { if (!h_class_loader.is_null()) { _class_loader = _handles.add(h_class_loader()); + _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().
*** 949,961 **** // 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"); return _name_and_id->as_C_string(); } } void ClassLoaderData::print_value_on(outputStream* out) const { if (!is_unloading() && class_loader() != NULL) { --- 949,963 ---- // 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 if (_name_and_id != NULL) { return _name_and_id->as_C_string(); + } else { + // May be called in a race before _name_and_id is initialized. + return _class_loader_klass->external_name(); } } void ClassLoaderData::print_value_on(outputStream* out) const { if (!is_unloading() && class_loader() != NULL) {
*** 1070,1080 **** 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); } return loader_data; } void ClassLoaderDataGraph::oops_do(OopClosure* f, bool must_claim) { --- 1072,1082 ---- 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(loader); } return loader_data; } void ClassLoaderDataGraph::oops_do(OopClosure* f, bool must_claim) {
< prev index next >