Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Util {
- public static void main(String[] args) {
- try {
- throw new Throwable("msg");
- } catch (Throwable t) {
- throw sneakyThrow(t);
- }
- }
- static public RuntimeException sneakyThrow(Throwable t) {
- if (t == null)
- throw new NullPointerException();
- Util.<RuntimeException>sneakyThrow0(t);
- return null;
- }
- static private <T extends Throwable> void sneakyThrow0(Throwable t) throws T {
- throw (T) t;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment