The latest issue of our magazine Jayview is out with brand new look and feel. My contribution was a cool piece of code that gets rid of those annoying exceptions. However, during layouting the link to the source disappeared. Credit should of course go to Reinier Zwitserloot and his mail on Java Posse.
public class Sneak {
public static RuntimeException sneakyThrow(Throwable t) {
if ( t == null ) throw new NullPointerException("t");
Sneak.<RuntimeException>sneakyThrow0(t);
return null;
}
@SuppressWarnings("unchecked")
private static <T extends Throwable> void sneakyThrow0(Throwable t) throws T {
throw (T)t;
}
}
Jan Kronquist Consultant at Jayway







0 comments ↓
There are no comments yet...Kick things off by filling out the form below.
Leave a Comment