Yeah, i was reading about that one.  But it's only in the Sun VMs and
probably subject to change.

But hey, I just listed this as an exercise.  It just shows the
difference between checked and unchecked is one little byte. :)

On Aug 26, 1:44 pm, Marcelo Fukushima <takesh...@gmail.com> wrote:
> theres also a throwException(Throwable) in sun.misc.Unsafe - though to
> use that you really have to want to
>
> On Wed, Aug 26, 2009 at 12:30 AM, Christian
>
>
>
>
>
> Catchpole<christ...@catchpole.net> wrote:
>
> > 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. :)
>
> --http://mapsdev.blogspot.com/
> Marcelo Takeshi Fukushima
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to javaposse@googlegroups.com
To unsubscribe from this group, send email to 
javaposse+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to