Given that I basically want to eliminate checked exception usage and transform them to runtime exceptions, I would normally be doing something like this:
try {
If you're considering the other answer's use of Unsafe (I recommend not, but anyway), another option is to abuse generics to throw a checked exception with this evil pair of methods (from http://james-iry.blogspot.co.uk/2010/08/on-removing-java-checked-exceptions-by.html):
@SuppressWarnings("unchecked")
private static
A pervertException(Throwable x) throws T {
throw (T) x;
}
public static A chuck(Throwable t) {
return Unchecked.
pervertException(t);
}
You might also check out com.google.common.base.Throwables.getRootCause(Throwable)
and just print its (root) stack trace.