Code review request for checked/unchecked exception clarifications (original) (raw)

David Holmes - Sun Microsystems David.Holmes at Sun.COM
Fri Jan 8 06:42:54 UTC 2010


Peter Jones said the following on 01/08/10 15:44:

On Jan 8, 2010, at 12:16 AM, David Holmes - Sun Microsystems wrote:

Peter Jones said the following on 01/08/10 15:00:

Hi. Another nit: the wordings below seem to imply that "new Error()" and "new RuntimeException()" (i.e. not subclasses) make checked exceptions, but of course they are unchecked too. What wording do you think implies this?

These are quite clear: + * That is, {@code Error} and its subclasses are regarded as unchecked + * exceptions for the purposes of compile-time checking of exceptions. + *

{@code RuntimeException} and its subclasses are unchecked + * exceptions.

Yes, those seem fine-- I was referring to the excerpts that you had quoted earlier, from the Exception and Throwable docs:

+ *

The class {@code Exception} and any subclasses that are not also

+ * subclasses of {@link RuntimeException} are checked + * exceptions.

+ * For the purposes of compile-time checking of exceptions, {@code + * Throwable} and any subclass of {@code Throwable} that is not also a + * subclass of either {@link RuntimeException} or {@link Error} are + * regarded as checked exceptions. In JLS usage I don't think that subclass is a reflexive relation (like subtype is). Compare the section 11.2 wording, "RuntimeException and its subclasses", etc.: http://java.sun.com/docs/books/jls/thirdedition/html/exceptions.html#44121

Ah I see. Yes in isolation those sentences do seem to exclude Error and RuntimeException themselves.

David



More information about the core-libs-dev mailing list