8203455: jcmd: VM.metaspace: print loader name for anonymous CLDs
Reviewed-by: lfoltan, goetz
This commit is contained in:
parent
e85e0f5daf
commit
611c72e5bc
src/hotspot/share
test/hotspot/jtreg/runtime/Metaspace
@ -400,9 +400,16 @@ class ClassLoaderData : public CHeapObj<mtClass> {
|
||||
static ClassLoaderData* class_loader_data_or_null(oop loader);
|
||||
static ClassLoaderData* anonymous_class_loader_data(Handle loader);
|
||||
|
||||
|
||||
// Returns Klass* of associated class loader, or NULL if associated loader is <bootstrap>.
|
||||
// Also works if unloading.
|
||||
Klass* class_loader_klass() const { return _class_loader_klass; }
|
||||
|
||||
// Returns Name of associated class loader.
|
||||
// Returns NULL if associated class loader is <bootstrap> or if no name has been set for
|
||||
// this loader.
|
||||
// Also works if unloading.
|
||||
Symbol* class_loader_name() const { return _class_loader_name; }
|
||||
|
||||
JFR_ONLY(DEFINE_TRACE_ID_METHODS;)
|
||||
};
|
||||
|
||||
|
@ -22,7 +22,8 @@
|
||||
*
|
||||
*/
|
||||
#include "precompiled.hpp"
|
||||
#include "classfile/classLoaderData.hpp"
|
||||
#include "classfile/classLoaderData.inline.hpp"
|
||||
#include "classfile/javaClasses.hpp"
|
||||
#include "memory/metaspace/printCLDMetaspaceInfoClosure.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "runtime/safepoint.hpp"
|
||||
@ -63,17 +64,44 @@ void PrintCLDMetaspaceInfoClosure::do_cld(ClassLoaderData* cld) {
|
||||
|
||||
_out->print(UINTX_FORMAT_W(4) ": ", _num_loaders);
|
||||
|
||||
if (cld->is_anonymous()) {
|
||||
_out->print("ClassLoaderData " PTR_FORMAT " for anonymous class", p2i(cld));
|
||||
// Print "CLD for [<loader name>,] instance of <loader class name>"
|
||||
// or "CLD for <anonymous class>, loaded by [<loader name>,] instance of <loader class name>"
|
||||
|
||||
ResourceMark rm;
|
||||
const char* name = NULL;
|
||||
const char* class_name = NULL;
|
||||
|
||||
// Note: this should also work if unloading:
|
||||
Klass* k = cld->class_loader_klass();
|
||||
if (k != NULL) {
|
||||
class_name = k->external_name();
|
||||
Symbol* s = cld->class_loader_name();
|
||||
if (s != NULL) {
|
||||
name = s->as_C_string();
|
||||
}
|
||||
} else {
|
||||
ResourceMark rm;
|
||||
_out->print("ClassLoaderData " PTR_FORMAT " for %s", p2i(cld), cld->loader_name());
|
||||
name = "<bootstrap>";
|
||||
}
|
||||
|
||||
// Print
|
||||
_out->print("CLD " PTR_FORMAT, p2i(cld));
|
||||
if (cld->is_unloading()) {
|
||||
_out->print(" (unloading)");
|
||||
}
|
||||
_out->print(":");
|
||||
if (cld->is_anonymous()) {
|
||||
_out->print(" <anonymous class>, loaded by");
|
||||
}
|
||||
if (name != NULL) {
|
||||
_out->print(" \"%s\"", name);
|
||||
}
|
||||
if (class_name != NULL) {
|
||||
_out->print(" instance of %s", class_name);
|
||||
}
|
||||
|
||||
_out->cr();
|
||||
|
||||
// Print statistics
|
||||
this_cld_stat.print_on(_out, _scale, _break_down_by_chunktype);
|
||||
_out->cr();
|
||||
|
||||
|
@ -73,7 +73,7 @@ public class PrintMetaspaceDcmd {
|
||||
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.metaspace", "show-loaders"});
|
||||
output = new OutputAnalyzer(pb.start());
|
||||
output.shouldHaveExitValue(0);
|
||||
output.shouldMatch("ClassLoaderData.*for <bootloader>");
|
||||
output.shouldMatch("CLD.*<bootstrap>");
|
||||
|
||||
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.metaspace", "by-chunktype"});
|
||||
output = new OutputAnalyzer(pb.start());
|
||||
|
Loading…
x
Reference in New Issue
Block a user