Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/hotspot/share/memory/heapInspection.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -600,12 +600,15 @@ void PrintClassLayout::print_class_layout(outputStream* st, char* class_name) {
return;
}

Thread* THREAD = Thread::current();
for (char* p = class_name; *p != '\0'; p++) {
if (*p == JVM_SIGNATURE_DOT) {
*p = JVM_SIGNATURE_SLASH;
}
}

Symbol* classname = SymbolTable::probe(class_name, (int)strlen(class_name));

GrowableArray<Klass*>* klasses = new (mtServiceability) GrowableArray<Klass*>(100, mtServiceability);

FindClassByNameClosure fbnc(klasses, classname);
cit.iterate(&fbnc);

Expand All @@ -614,9 +617,9 @@ void PrintClassLayout::print_class_layout(outputStream* st, char* class_name) {
if (!klass->is_instance_klass()) continue; // Skip
InstanceKlass* ik = InstanceKlass::cast(klass);
int tab = 1;
st->print_cr("Class %s [@%s]:", klass->name()->as_C_string(),
klass->class_loader_data()->loader_name());
ResourceMark rm;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may still need this to limit the ResourceArea usage, otherwise you will be keeping all allocations from the complete loop alive.

st->print_cr("Class %s [@%s]:", klass->external_name(),
klass->class_loader_data()->loader_name());
Comment thread
caspernorrbin marked this conversation as resolved.
Outdated
GrowableArray<FieldDesc>* fields = new (mtServiceability) GrowableArray<FieldDesc>(100, mtServiceability);
for (AllFieldStream fd(ik); !fd.done(); fd.next()) {
if (!fd.access_flags().is_static()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ static void testCmd(String arg, int expectExitCode, String... expectStrings) thr
}

public static void main(String args[]) throws Exception {
testCmd("foo/bar", 0, "");
testCmd("foo.bar", 0, "");
testCmd("", 1, "IllegalArgumentException", "mandatory");
testCmd("java/lang/Object", 0, "java/lang/Object", "@bootstrap");
testCmd("java/lang/Class", 0, "java/lang/Class", "@bootstrap");
testCmd("runtime/valhalla/inlinetypes/ClassPrintLayoutDcmd$Line", 0, "@app", "p1", "p2");
testCmd("java.lang.Object", 0, "java.lang.Object", "@bootstrap");
testCmd("java.lang.Class", 0, "java.lang.Class", "@bootstrap");
testCmd("runtime.valhalla.inlinetypes.ClassPrintLayoutDcmd$Line", 0, "@app", "p1", "p2");
}
}