Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Minor edit

...

Unchecked exception classes such as Error and its subclasses are not subject to compile-time checking because it is tedious to account for all exceptional conditions and recovery is generally difficult. However, even if recovery is impossible, the JVM allows a graceful exit and a chance to at least log the error. This is made possible by using a try-catch block that catches Throwable. Also, when code must not leak potentially sensitive information, catching Throwable is permitted. In all other cases, catching Throwable is not recommended. Where cleanup operations such as releasing system resources are possible, code should use a finally block and do the needfulwithin which the resources should be released, or use a try-with-resources statement.

Noncompliant Code Example

...