-
Notifications
You must be signed in to change notification settings - Fork 0
FAQ
zleonov edited this page Dec 7, 2023
·
4 revisions
- Why am I getting an error that the unchecked method is ambigous
- Why are you handling all Exceptions instead of all Throwables?
This error can occur when you are using multiple unchecked methods with static imports. The root cause of this error is Java's type erasure because the compiler cannot infer generic arguments at runtime. The easiest solution is to remove the static import.
For example we can change Stream.of(...).map(unchecked(URL::new))
to Stream.of(...).map(CheckedFunction.unchecked(URL::new))
.
I considered that before. I don't often see code that actually throws Throwable
instead of Exception
. But I am willing to entertain the possibility that Unchecked Java should uniformly handle Throwable
s instead of Exception
s.