Feedback about structured Concurrency and proposing of a new functional interface akin runnable

Alan Bateman alan.bateman at oracle.com
Fri Sep 5 11:09:57 UTC 2025


On 04/09/2025 04:15, david Grajales wrote:
> :
>
> One thing I noticed is that having to declare |Void| and return |null| 
> introduces a bit of noise. This ceremony is required because 
> |Runnable| doesn’t allow checked exceptions in its contract (and never 
> will, for backwards compatibility). Yet, in practice, many real-world 
> tasks don’t return values directly — instead, they write to or consume 
> from buffers.
>
> This makes the |Void| return type and |return null| feel redundant. I 
> was wondering: would it be worth considering the addition of a 
> |Runnable|-like functional interface that permits checked exceptions?
>

Runnable and Callable are familiar to all of APIs in this area. We've 
avoided introducing throwing-Runnable or throwing-Supplier functional 
interfaces as adding any throwing interface to j.u.function opens the 
door to requests to add more. It might also be that someday there are 
changes to the language for exception transparency or maybe allowing 
overriding with an unboxed return. So maybe in the future need for such 
interfaces may go away (I can't speak to any specific plans of course, 
instead just saying that we've been conservative about adding throwing 
variants that could potentially be obsolete in the future).

-Alan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20250905/f7b2599e/attachment-0001.htm>


More information about the loom-dev mailing list