On Thu, 23 Oct 2025 16:22:00 GMT, Alan Bateman <[email protected]> wrote:
>> src/java.base/share/classes/java/util/concurrent/Joiners.java line 99:
>>
>>> 97: throw ex;
>>> 98: } else {
>>> 99: return subtasks.stream().map(Subtask::get).toList();
>>
>> Since the `subtasks` won't get collected until after the scope gets
>> collected, we should probably clear the original collection before returning
>> the resulting List.
>
> The default (awaitAllSuccessFulOrThrow) doesn't keep anything alive. However,
> allSuccessFulOrThrow and allUntil do to allow for Joiner.result be called
> again. It's a bit an off piste usage to invoke directly but isn't prohibited:
>
> "In normal usage, this method will be called at most once by the join method
> to produce the result (or exception). The behavior of this method when
> invoked directly, and invoked more than once, is undefined. Where possible,
> an implementation should return an equal result (or throw the same exception)
> on second or subsequent calls to produce the outcome."
>
> We haven't changed anything in this update but we could drop the sentence
> about setting expectations about produce the same result.
Yeah, I think it makes sense to spec it to be at use at most once (then you can
compute results freely as no one is expected that repeated invocations will be
near-constant). Then we could amend the implementations to scrap the
intermediate storage as the method is invoked.
>> src/java.base/share/classes/java/util/concurrent/StructuredTaskScope.java
>> line 334:
>>
>>> 332: * #fork forking} of a subtask {@linkplain
>>> java.util.concurrent##MemoryVisibility
>>> 333: * <i>happen-before</i>} any actions taken by that subtask, which in
>>> turn
>>> 334: * <i>happen-before</i> the subtask result is {@linkplain
>>> Subtask#get() retrieved}.
>>
>> This may be interpreted as users calling result() so it might be worth
>> clarifying it as:
>>
>> "<i>happen-before</i> the subtask result is {@linkplain Subtask#get()
>> retrieved} by {@linkplain #join() join()}
>
> The only change here is using the "##" in the link. So this is pre-existing
> wording (not changed in this update). I agree it could be mis-read and okay
> to change it. I think it's more about extending it for when a result (from
> join) is derived from the result of a subtask. I'll see if I can come up with
> better wording.
Sounds great, thanks Alan!
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27392#discussion_r2459742888
PR Review Comment: https://git.openjdk.org/jdk/pull/27392#discussion_r2459744089