Rethrown exception disregarded
public void badmethod() throws Exception { boolean error = false; try { throw new Exception(); } catch (Exception e) { error = true; throw e; } finally { if (error) return; } } public void testbadmethod() { try { badmethod(); System.out.println("WRONG"); } catch (Exception ae) { System.out.println("RIGHT"); } }It prints out "WRONG". i.e., with return statement in finally caluse, the rethrown exception is swallowed.
No comments:
Post a Comment