158 karma · joined July 17, 2012
public static RuntimeException unchecked(Exception e) {
Exceptions.<RuntimeException>throw_checked(e);
return null;
}
private static <E extends Exception> void throw_checked(Exception e) throws E {
throw (E) e;
}
then you can do this: try { ...
} catch (IOException e) {
throw unchecked(e);
}
And the original exception is thrown without being wrapped. It's as though you had `throws IOException` on your method signature.This is from my original solution to the problem: https://github.com/rogerkeays/jamaica-core/blob/0cc98b114998...
https://github.com/rogerkeays/unchecked/blob/f22c8cde3557de0...
No need to change the type hierarchy. Just make it a compiler option.
[EDIT] I moved the command line stuff back to the top of the README. XML makes my eyes bleed too...
I like his use of the word should, because as we all know it really means won't. I should exercise more, I should stop trolling people on reddit. API designers should control their APIs.
As for the technical objections, I think the conflict-management rules hold the most weight, but this problem is no more difficult than any other in language design. "not overrideable" is a feature, not a bug (can we please give up on behavioural inheritance already?), and discoverability already sucks. I mean, I still use duckduckgo to find javadocs.