Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: "Completing abruptly" changed to "Abrupt completion".

...

Code Block
bgColor#ccccff
class TryFinally {
  private static boolean doLogic() {
    try {
      throw new IllegalStateException();
    } finally {
      int c;
      try {
        while ((c = input.read()) != -1) {
          if (c > 128) {
            break;
          }
        }
      } catch (IOException x) {
        // forward to handler
      }
      System.out.println("logic done");
    }
    // Any return statements must go here; applicable only when exception is thrown conditionally
  }
}

Risk Assessment

Completing abruptly from Abrupt completion of a finally block masks any exceptions thrown inside the associated try and catch blocks.

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="8a949e62da4567ad-e1963be3-4d934236-97bf822f-65d68c28d16a89f61e48fe22"><ac:plain-text-body><![CDATA[

[[Bloch 2005

AA. References#Bloch 05]]

Puzzle 36. Indecision

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="0c1dd9ec6f6f9010-0d398527-464d4958-bf22a5aa-c8e16a9694e9c6664198ed7e"><ac:plain-text-body><![CDATA[

[[Chess 2007

AA. References#Chess 07]]

8.2, Managing Exceptions, The Vanishing Exception

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="2574dffa179f3ce6-89d19f15-4ed74887-94cfb647-7f53e4fe1b340178a0b4b965"><ac:plain-text-body><![CDATA[

[[JLS 2005

AA. References#JLS 05]]

[§14.20.2, Execution of try-catch-finally

http://java.sun.com/docs/books/jls/third_edition/html/statements.html#14.20.2]

]]></ac:plain-text-body></ac:structured-macro>

...