RFR: 8127: Use ProcessHandle API to get PIDs
Christoph Langer
clanger at openjdk.org
Sun Oct 15 10:34:22 UTC 2023
On Sun, 8 Oct 2023 10:24:53 GMT, Christoph Dreis <duke at openjdk.org> wrote:
> Hi,
>
> this PR uses `ProcessHandle.current().pid()` that was introduced in Java 9 rather than parsing the output of `ManagementFactory.getRuntimeMXBean().getName()`.
>
> If you think this is worthwhile, I'd appreciate a ticket and sponsoring.
>
> Cheers,
> Christoph
Good simplification. I think the try/catch in Environment::initPID() is obsolete now.
core/org.openjdk.jmc.common/src/main/java/org/openjdk/jmc/common/util/Environment.java line 136:
> 134: try {
> 135: return (int) ProcessHandle.current().pid();
> 136: } catch (Exception e) {
I think the try/catch is not needed with ProcessHandle any more...
-------------
Marked as reviewed by clanger (Committer).
PR Review: https://git.openjdk.org/jmc/pull/522#pullrequestreview-1678768003
PR Review Comment: https://git.openjdk.org/jmc/pull/522#discussion_r1359850176
More information about the jmc-dev
mailing list