Skip to content
zleonov edited this page Dec 7, 2023 · 4 revisions

Frequently Asked Questions

Why am I getting an error that the unchecked method is ambigous?

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)).

Why are you handling all Exceptions instead of all Throwables?

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 Throwables instead of Exceptions.