Bikeshedding Structured Concurrency

George Ball george at jgserv.co.uk
Fri Aug 1 12:16:50 UTC 2025


My understanding ( and I may be way off here… )   

The “feature” provided by exceptions et al has been around in various languages for a long time, pre-Java, so the term had a level of familiarity when Java came out. Java’s approach however of having different “types” of exception encoded in the type system led the class hierarchy with a common base class Throwable. There’s checked and unchecked Exceptions, which extend the Exception class which extends Throwable. But then we also have Error which extends Throwable but is the base of a second hierarchy representing “bad things” that are not intended to be caught… So we can think of Exceptions as things that are throwable and may be caught within application code.

It remains an open question whether the idea of checked/unchecked exceptions is good or not - and many strong opinions can be found on this topic so I don’t need to say any more :)  

Hope that makes sense :)

George


> On 1 Aug 2025, at 12:51, David Alayachew <davidalayachew at gmail.com> wrote:
> 
> Thanks for the responses everyone. It appears that there are several examples that return too. Sounds like the reason is convention then.
> 
> I guess a better question might be, why were all these API's named with Exception rather than Throwable in the first place? What benefit is there in naming it Exception?
> 
> On Fri, Aug 1, 2025, 4:47 AM Remi Forax <forax at univ-mlv.fr <mailto:forax at univ-mlv.fr>> wrote:
>> 
>> 
>> From: "Alan Bateman" <alan.bateman at oracle.com <mailto:alan.bateman at oracle.com>>
>> To: "David Alayachew" <davidalayachew at gmail.com <mailto:davidalayachew at gmail.com>>, "loom-dev" <loom-dev at openjdk.org <mailto:loom-dev at openjdk.org>>
>> Sent: Friday, August 1, 2025 10:28:04 AM
>> Subject: Re: Bikeshedding Structured Concurrency
>> On 01/08/2025 06:05, David Alayachew wrote:
>> Hello @loom-dev <mailto:loom-dev at openjdk.org>,
>> 
>> I have been enjoying the Structured Concurrency JEP's as they have come, and I am excited to try the JDK 25 variant with all the new changes with Joiner.
>> 
>> I have a bikeshed request.
>> 
>> For Subtask, can we change the method name from exception() to throwable()? It more accurately describes what is happening.
>> 
>> 
>> In j.u.concurrent there is CompletableFuture.completeExceptionally(Throwable)/obtrudeException(Throwable), SubmissionPublisher.closeExceptionally(Throwable), ForkJoinTask.getException and Future.exceptionNow() returning a Throwable, and a few more.
>> 
>> yes, also Future.exceptionNow().
>> 
>> 
>> 
>> The main use of Subtask::exception will be a custom Joiner's onComplete implementation where handles the exception or error when the subtask fails. There is an argument that fork should be void or just return a Supplier (Subtask extends Supplier) but there hasn't been enough feedback from real-world usage to help that discussion.
>> 
>> -Alan
>> 
>> Rémi
>> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20250801/746e2283/attachment.htm>


More information about the loom-dev mailing list