RFR: 8336479: Provide Process.waitFor(Duration)

ExE Boss duke at openjdk.org
Wed Jul 17 20:03:31 UTC 2024


On Wed, 17 Jul 2024 18:31:32 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> 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?
>
>> waitFor can be overridden by pre-24 subclasses to provide a better implementation while ...
> 
> It doesn't really make sense to extend Process, except maybe for mocking or other testing. Process is really for JDK implementations, it's just historical the constructor is public. Just saying that the compatibility concerns with adding methods aren't significant here.

This method needs to be overridden in `test/lib/jdk/test/lib/process/ProcessTools.java` to call `ProcessTools.ProcessImpl::waitForStreams`.

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

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


More information about the core-libs-dev mailing list