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="6c3f5ff9abaad7ce-b9112421-434d4e88-a7b08ce7-55cd2828a080cdd068d47bcd"><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="d24701a307a479d9-40f401ac-4d8044da-80fd8618-e90eece4ed237f9a59420aa0"><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="c7065b0e424545e8-4be73994-4df3474a-9f1391b8-424975307a09e89959b7bccf"><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>

...