

For example with Files if your application logger can't write its data would you rather be forced to catch a potential IOException and recover, or have something that may not be critical to your app bring down the whole JVM because no one thought to catch the unchecked Exception (as you may have guessed, I'll choose the former). A RuntimeException is one which most typically denotes a serious error in the logic of the programming (such as ArrayIndexOutOfBounds, NullPointer, or IllegalArgument) or something that the runtime has otherwise determined really shouldn't be happening (such as SecurityException).Ĭonversely IOException and its derivatives are exceptions that could reasonably occur during normal execution of a program, and common logic would dictate that either those problems should be dealt with, or at least the programmer should be aware that they can occur. Is this generally the case? Can a Java application correct I/O errors or wait for the system to recover? If so, then it is reasonable for IOException to be checked, but if it is not the case, then IOException should be unchecked so that business logic can delegate handling of this exception to a separate system error handler. In When You Can't Throw An Exception, Elliotte Rusty Harold claims that most I/O errors are transient and so you can retry an I/O operation several times before giving up:

I think that class IOException should have been an unchecked exception because there is little that an application can do to resolve problems like file system errors.

Do you agree that the designers of Java class java.io.IOException should have made it an unchecked run-time exception derived from instead of a checked exception derived only from ?
