News for hackers. Stuff that matters.
Re:JEP draft: Exception handling in switch by PhilipRoman on Friday April 19, 2024 @03:25PM (#40091004)
I'd say it is due to a lack of variadic type parameters. You can write something like this:

    <T, X extends Throwable> void forEach(ThrowingConsumer<T, X> f) throws X;
But the only way to have multiple exception types without losing static type checking is to have multiple X parameters, like X1, X2, X3... (with unused parameters being set to some subtype of RuntimeException so that they do not participate in checked exception handling).

Whether or not it is worth to write this madness just to satisfy one's OCD is up to the reader.

Re:JEP draft: Exception handling in switch by ackfoobar on Friday April 19, 2024 @03:38PM (#40091133)
> it is due to a lack of variadic type parameters

To be pedantic, it is due to union types "not complemented anywhere else in Java's type system". Adding variadic type params is a way to solve this. Another way is, of course, to support union types.

> with unused parameters being set to some subtype of RuntimeException

Or the `Nothing` type (`never` in TypeScript), where `A | Nothing = A`.