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.