From my understanding, Unsafe.throwException throws the passed Throwable, more commonly known as "snaky throws".

There are other ways to archive the same result, one commonly found is by (ab)using generics:

    public static <T extends Throwable> void sneakyThrows(Throwable t) throws T {
        throw (T) t;
    }

(This will generate an unchecked warning, but that can be silenced with the right annotation.)

Is there any reason why this method still needs to exist?
If not, could it be removed?

- Johannes

Reply via email to