Anders Nordås shows how to throw a checked exception without declaring a throws clause. The method uses some inherently evil mechanisms (the name of the class “sun.misc.Unsafe” should be a tip of), and like Anders says, this should probably never be used in production.Basically, calling sun.misc.Unsafe.throwException will throw a checked exception without alerting the compiler. The exception is not wrapped, but it cannot be caught by its class name, as it is not declared. Here is some code to illustrate:<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> PureEvilness <span style="color: #66cc66;">{</span> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #993333;">void</span> throwIt<span style="color: #66cc66;">(</span><span style="color: #aaaadd; font-weight: bold;">IOException</span> exception<span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #808080; font-style: italic;">// See Anders' blog for implementation</span> <span style="color: #808080; font-style: italic;">// Notice: No "throws" clause!</span> <span style="color: #66cc66;">}</span> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #993333;">void</span> main<span style="color: #66cc66;">(</span><span style="color: #aaaadd; font-weight: bold;">String</span><span style="color: #66cc66;">[</span><span style="color: #66cc66;">]</span> args<span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #808080; font-style: italic;">/* * Error: "Unreachable catch block for IOException. * This exception is never thrown from the try statement block" try { throwIt(new IOException()); } catch (IOException e) { // Deal } */</span> <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #66cc66;">{</span> throwIt<span style="color: #66cc66;">(</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">IOException</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>; <span style="color: #66cc66;">}</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">(</span><span style="color: #aaaadd; font-weight: bold;">Exception</span> e<span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span>e.<span style="color: #006600;">getClass</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span> == <span style="color: #aaaadd; font-weight: bold;">IOException</span>.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span> <span style="color: #aaaadd; font-weight: bold;">System</span>.<span style="color: #006600;">err</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"It was an IOException!"</span><span style="color: #66cc66;">)</span>; <span style="color: #66cc66;">}</span> <span style="color: #808080; font-style: italic;">// Deal</span> <span style="color: #66cc66;">}</span> <span style="color: #66cc66;">}</span> <span style="color: #66cc66;">}</span>The wonders of checked exceptions never cease. Java