4 ms·
There is no need to get rid of checked exceptions to fix that. You need generics for exceptions. If the inner function can throw some exception, then it should
by lokedhs 7y ago
There is no need to get rid of checked exceptions to fix that.
You need generics for exceptions. If the inner function can throw some exception, then it should be possible to declare the stream method that it will throw the same exception.
I believe that the JVM doesn't actually support this, so the reasons were got the horrible situation we're in is because they didn't want to sacrifice backward compatibility.
- erik_seaberg 7y agoI think we're saying the same thing. If f(T) can return U or throw A or B or C, there needs to be a way to declare that Stream<T>#map takes a Function<T, U, A|B|C> and returns a Stream<U> or throws A or B or C. But that sum type A|B|C doesn't exist in Java if there's no common base class.