| public interface IFoo { /** * This method can't throw any checked exceptions...or can it? */ void bar (); } // End of interface |
| try { IFoo foo = ... // get an IFoo implementation foo.bar (); } catch (RuntimeException ioe) { // Handle 'ioe' ... } catch (Error e) { // Handle or re-throw 'e' ... } |
| public void bar () { EvilThrow.throwThrowable (m_throwthis); } |
| public class Main { public static void main (final String[] args) { // This try/catch block appears to intercept all exceptions that // IFoo.bar() can throw; however, this is not true try { IFoo foo = new EvilFoo (new java.io.IOException ("SURPRISE!")); foo.bar (); } catch (RuntimeException ioe) { // Ignore ioe } catch (Error e) { // Ignore e } } } // End of class |
| >java -cp classes Main Exception in thread "main" java.io.IOException: SURPRISE! at Main.main(Main.java:23) |