RFR: 8319589: Attach from root to a user java process not supported in Mac [v3]
David Holmes
dholmes at openjdk.org
Tue Sep 23 21:56:07 UTC 2025
On Tue, 23 Sep 2025 16:57:34 GMT, Sergey Chernyshev <schernyshev at openjdk.org> wrote:
>> src/jdk.attach/macosx/classes/sun/tools/attach/VirtualMachineImpl.java line 49:
>>
>>> 47: // the latter can be changed by the user.
>>> 48: // Any changes to this needs to be synchronized with HotSpot.
>>> 49: private static final String tmpdir;
>>
>> So we can't cache this any more?
>
> Thanks David for pointing this out. A different instance with a different PID may have a different temp path, so the path should be specific to the instance. Since we don't need the path outside the constructor, I think we don't need to cache it. On the other hand I see that `getTempDirFromPid` is called twice, once for `.java_pid` and another time in `createAttachFile` when `.java_pid` doesn't exist. Would you suggest storing the path in a local variable in the constructor and then concatenating it with attach file name, or would a non-static member variable be more suitable for this?
I would save it in a local in the constructor and pass it to `createAttachFile` rather than passing the pid.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25824#discussion_r2373540696
More information about the serviceability-dev
mailing list