-
Notifications
You must be signed in to change notification settings - Fork 169
8383567: [lworld] VM.class_print_layout should use external class names #2375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: lworld
Are you sure you want to change the base?
Changes from 2 commits
2bdaa63
c8df796
eb127d3
6baa184
7a18def
d1ffe8a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
|
|
@@ -600,12 +600,17 @@ void PrintClassLayout::print_class_layout(outputStream* st, char* class_name) { | |
| return; | ||
| } | ||
|
|
||
| Thread* THREAD = Thread::current(); | ||
|
|
||
| Symbol* classname = SymbolTable::probe(class_name, (int)strlen(class_name)); | ||
| ResourceMark rm; | ||
| char* normalized_name = NEW_RESOURCE_ARRAY(char, strlen(class_name) + 1); | ||
| strcpy(normalized_name, class_name); | ||
| for (char* p = normalized_name; *p != '\0'; p++) { | ||
| if (*p == '.') { | ||
| *p = '/'; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should use
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't know these existed, but I swapped to use these now. |
||
| } | ||
| } | ||
| Symbol* classname = SymbolTable::probe(normalized_name, (int)strlen(normalized_name)); | ||
|
|
||
| GrowableArray<Klass*>* klasses = new (mtServiceability) GrowableArray<Klass*>(100, mtServiceability); | ||
|
|
||
| FindClassByNameClosure fbnc(klasses, classname); | ||
| cit.iterate(&fbnc); | ||
|
|
||
|
|
@@ -614,9 +619,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; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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()); | ||
|
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()) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have to make a copy here rather than modifying in place? The user-supplied string is already in a mutable C-heap allocated buffer, as processed by the DCmd framework. If we think it inappropriate to modify at this level perhaps we can push the conversion up into the DCmd framework itself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's already a
Symbol::as_klass_external_name(char* buf, int size)method to do the '/'s into '.'s conversion. Should this code be moved to a newSymbol::as_klass_internal_name(char* buf, int size)method?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kept it in the same location as of now, but removed the extra allocation. I don't think putting it in
Symbolis the right place, because here we are just modifying a mutablechar*. So the operation is not really on a symbol. But it could perhaps be moved to where we parse the DCmd instead, if you feel like it doesn't belong here.