/** * Rethrows a checked exception as unchecked exception. This method tricks the compiler into * thinking the exception is unchecked, rather than wrapping the given exception in a new * {@code RuntimeException}. * <p> * This method never returns. Nevertheless, it specifies a return type so it can be invoked as * {@code throw unchecked(exc)} in contexts where an exception type is syntactically required * (e.g. when the enclosing method is non-void). * * @param exc * checked exception * @return syntactically, a runtime exception (but never actually returns) */ public static RuntimeException unchecked(Throwable exc) { Exceptions.<RuntimeException> adapt(exc); return null; }