I propose a utility-class with something like this, and we're good to go:
public static void throwUnchecked(final Throwable pException) { // Type parameter to Thrower is erased at compile-time new Thrower().sneakyThrow(pException); }
private static class Thrower { private void sneakyThrow(Throwable pException) throws T { throw (T) pException; // Unchecked cast } }
I'm starting to think this might be useful.. Or... Maybe I'm just tired.. :-P