The runtime exception classes (RuntimeException
and its subclasses) are
exempted from compile-time checking because, in the judgment of the designers
of Java, having to declare such exceptions would not aid significantly in establishing the correctness of Java programs. Many of the operations and constructs of the
Java language can result in runtime exceptions. The information available to a
Java compiler, and the level of analysis the compiler performs, are usually not sufficient to establish that such runtime exceptions cannot occur, even though this
may be obvious to the Java programmer. Requiring such exception classes to be
declared would simply be an irritation to Java programmers.
For example, certain code might implement a circular data structure that, by construction, can never involve null
references; the programmer can then be certain that a NullPointerException
cannot occur, but it would be difficult for a compiler to prove it. The theorem-proving technology that is needed to establish such global properties of data structures is beyond the scope of this Java Language Specification.