RFR: 8367857: Implement JEP 525: Structured Concurrency (Sixth Preview) [v3]

Pavel Rappo prappo at openjdk.org
Tue Oct 21 11:44:10 UTC 2025


On Tue, 21 Oct 2025 10:53:19 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Updates for JEP 525.
>> 
>> - `Joiner:onTimeout` is added  with `join` method changed to invoke this joiner method if
>>   a timeout is configured and the timeout expires before or while waiting. The `onTimeout`
>>   throws `TimeoutException` or may do nothing. This allows for `Joiner` implementation that
>>   are capable of returning a result from the subtasks that complete before the timeout expires.
>> - The `configFunction` parameter to the 3-arg `open` is changed from
>>   `Function<Configuration, Configuration>` to `UnaryOperator<Configuration>`.
>> - `Subtask::get` and `Subtask::exception` changed to consistently throw if called from
>>   any thread before the scope owner has joined.
>> - `StructuredTaskScope::join` is now specified so that it may be called again if interrupted.
>> - The parameter on `Joiner::onFork` and `Joiner::onComplete` is changed from
>>   `Subtask<? extends T` to `Subtask<T>`.
>> - `Joiner.allSuccessOrThrow` is changed to return a list of results instead of a stream of
>>   subtasks. `Joiner.allUntil` is changed to return a list of subtasks.
>> - `Joiner.anySuccessfulResultOrThrow` is renamed to `anySuccessfulOrThrow`.
>> - `Joiner.allUntil(Predicate)` is changed to allow `join` return the stream of all forked
>> subtasks when the timeout expires.
>> - `Joiner` is no longer a `@FunctionalInterface`.
>> 
>> Most of the changes are to API docs and tests. Some links are changed to use double hash mark.
>
> Alan Bateman has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 13 additional commits since the last revision:
> 
>  - Merge branch 'master' into JDK-8367857
>  - Sync up from loom repo
>  - Merge branch 'master' into JDK-8367857
>  - Sync up from loom repo
>  - Merge branch 'master' into JDK-8367857
>  - Merge branch 'master' into JDK-8367857
>  - Improve docs and review feedback
>  - Merge branch 'master' into JDK-8367857
>  - Add JEP number
>  - Merge branch 'master' into JDK-8367857
>  - ... and 3 more: https://git.openjdk.org/jdk/compare/5f263255...e9ab6f18

I haven't been paying much attention to the recent previews of this feature, so feel free to point me to a relevant discussion elsewhere.

As I understand it, an unchecked StructuredTaskScope.TimeoutException was added in JDK 25. There's also the well-known checked java.util.TimeoutException. I assume that the namesake exception was added solely because it's unchecked. I also assume UncheckedTimeoutException was considered at some stage, because in my mind, the situation is similar to that of IOException/UncheckedIOException.

Why did you choose to add a namesake instead of an unchecked wrapper exception? Was it because you consider that the likelihood of mixing the two TimeoutException's is low in the context of a single file?

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

PR Comment: https://git.openjdk.org/jdk/pull/27392#issuecomment-3426171107


More information about the core-libs-dev mailing list