Checked exceptions: Java’s biggest mistake
BRANK

Checked exceptions have always been a controversial feature of the Java language.Advocates claim they ensure checking & recovery from failures. Detractors say “catch” blocks can almost never recover from an exception, and are a frequent source of mistakes.Meanwhile, Java 8 and lambdas are here. Are checked exceptions becoming obsolete in the Java world?The Intent of Checked ExceptionsIn the mid 90’s, James Gosling at Sun came up with a new language.At the time, C++ programming required every single function return to be checked for error. He decided there had to be a better way, and built the concept of “exceptions” into Java.The intent of checked exceptions was to locally flag, and force developers to handle, possible exceptions. Checked exceptions have to be declared on a method signature, or handled.This was intended to encourage software reliability & resilience. There was an intent to “recover” from contingencies – predictable outcomes other than success, such as Insuffic…

literatejava.com
Related Topics: Java