I know. The VM specification does not even need to know the Exception type. If 
you trick the Java compiler by generics to think the method cannot throw the 
exception it will simply compile the code. If the Exception that is thrown is 
checked that does not matter, the VM will bubble up until someone catches.

The only known other sneaky way is this:

static void sneakyThrow(Throwable t) {
  Thread.currentThread().stop(t);
}

But less cool, I agree. The third way is our all fried sun.misc.Unsafe:

Unsafe.theUnsafe.throwException(...)

(needs reflections, as always). Much more uncool.

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: [email protected]


> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On Behalf Of
> Dawid Weiss
> Sent: Thursday, March 29, 2012 9:21 PM
> To: [email protected]
> Subject: Re: [JENKINS] Lucene-Solr-tests-only-3.x - Build # 12908 - Failure
> 
> bq. Exploits a weakness in the runtime to throw an arbitrary throwable without
> the traditional declaration.
> 
> This is hardly a weakness; it's part of the JVM spec (or rather: the 
> distinction of
> checked/ unchecked is part of the Java specification not the JVM 
> specification).
> 
> > But it's in my opinion a generics bug in combination with
> > suppresswarnings
> 
> It's an exploit of how generics are (under)specified. Many people think 
> checked
> exceptions are actually a stupid invention, I think it's debatable, some of 
> them
> are really annoying...
> 
> Dawid
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected] For additional
> commands, e-mail: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to