On Tue, 18 Aug 2026 10:47:12 GMT, Johan Sjölen <[email protected]> wrote:

>> src/hotspot/share/memory/heapInspection.cpp line 600:
>> 
>>> 598:   }
>>> 599: 
>>> 600:   for (char* p = class_name; *p != '\0'; p++) {
>> 
>> Should we add a comment above the method to clarify that the string passed 
>> in argument might be modified?
>
> Yeah, I think this is introducing a footgun. We are already allocating with a 
> ResourceMark below, why not resource strdup the class_name and alter the 
> strdup?

We duplicate the string when parsing the `jcmd` and don't use it anywhere else, 
so it should be fine to modify. However, I agree that this could be a bit 
fragile. I pushed a change adding a resource `strdup` so we modify that 
instead, leaving the original untouched.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/32396#discussion_r3804378470

Reply via email to