RFR: 8336479: Provide Process.waitFor(Duration)

Chen Liang liach at openjdk.org
Wed Jul 17 18:09:57 UTC 2024


On Wed, 17 Jul 2024 17:36:29 GMT, Naoto Sato <naoto at openjdk.org> wrote:

> Proposing a new overload method for `Process#waitFor()` which takes a `Duration` for the timeout value. This will reduce the possibility for making mistakes with the `TimeUnit` in the other overload method. A corresponding CSR has also been drafted.

src/java.base/share/classes/java/lang/Process.java line 504:

> 502:             return false;
> 503: 
> 504:         return waitForNanos(TimeUnit.NANOSECONDS.convert(duration));

`waitFor` can be overridden by pre-24 subclasses to provide a better implementation while `waitForNanos` couldn't. Is it reasonable for our default implementation to delegate to `waitFor(long, TimeUnit)` that existing user classes have better implementations for?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20220#discussion_r1681464947


More information about the core-libs-dev mailing list