On Fri, 1 May 2026 14:23:48 GMT, Frederic Parain <[email protected]> wrote:

>> src/hotspot/share/memory/heapInspection.cpp line 605:
>> 
>>> 603:   ResourceMark rm;
>>> 604:   char* normalized_name = NEW_RESOURCE_ARRAY(char, strlen(class_name) 
>>> + 1);
>>> 605:   strcpy(normalized_name, class_name);
>> 
>> 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'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 
> new `Symbol::as_klass_internal_name(char* buf, int size)` method?

I kept it in the same location as of now, but removed the extra allocation. I 
don't think putting it in `Symbol` is the right place, because here we are just 
modifying a mutable `char*`. 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.

-------------

PR Review Comment: 
https://git.openjdk.org/valhalla/pull/2375#discussion_r3181299088

Reply via email to