Compile this.. (any package you like, or no package at all)
public class Rethrow {
public static void unchecked(Throwable t) {
t=t;
}
}
javap reports the byte code as..
public static void unchecked(java.lang.Throwable);
Code:
Stack=1, Locals=1, Args_size=1
0: aload_0
1: astore_0
2: return
which in hex is:
2A 4B B1
open the class file in the hex editor, search for that and change it
to:
2A BF B1
javap now reports the byte code as..
public static void unchecked(java.lang.Throwable);
Code:
Stack=1, Locals=1, Args_size=1
0: aload_0
1: athrow
2: return
jar that class up or otherwise protect it from re-write.
In your code you can now call this without wrapping with a runtime
exception. And the stack trace is still that of the original
exception.
} catch(Exception e) {
Rethrow.unchecked(e);
}
Obviously, use at your own risk. No warrenties etc. :)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "The
Java Posse" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaposse?hl=en
-~----------~----~----~----~------~----~------~--~---