RFR: 8254102: use ProcessHandle::pid instead of ManagementFactory::getRuntimeMXBean to get pid in tests
Roger Riggs
rriggs at openjdk.java.net
Wed Oct 7 02:02:05 UTC 2020
On Tue, 6 Oct 2020 23:08:40 GMT, Igor Ignatyev <iignatyev at openjdk.org> wrote:
> Hi all,
>
> could you please review this small cleanup which replaces
> `ManagementFactory.getRuntimeMXBean().getName().split("@")[0]` w/ `ProcessHandle.current().pid()` to get current
> process pid? Thanks,
> -- Igor
All of these changes can call `ProcessHandle.current().toString()` to return pid of the current process.
test/failure_handler/test/sanity/Suicide.java line 36:
> 34: String osName = System.getProperty("os.name");
> 35: if (osName.contains("Windows")) {
> 36: cmd = "taskkill.exe /F /PID " + pidStr;
This can be simplified to ProcessHandle.current().toString(). It returns the pid of the process as a string.
Explicitly converting it to a string is not necessary. The "+" concatenation would convert the number to a string.
-------------
Changes requested by rriggs (Reviewer).
PR: https://git.openjdk.java.net/jdk/pull/534
More information about the build-dev
mailing list