Code review request for checked/unchecked exception clarifications

Peter Jones pcj at roundroom.net
Fri Jan 8 05:44:08 UTC 2010


Hi David,

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.
> 
> + * <p>{@code RuntimeException} and its subclasses are <em>unchecked
> + * exceptions</em>.

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

>>>> + * <p>The class {@code Exception} and any subclasses that are not also
>>>> + * subclasses of {@link RuntimeException} are <em>checked
>>>> + * exceptions</em>.
>>>> 
>>>> + * 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/third_edition/html/exceptions.html#44121

Cheers,
-- Peter




More information about the core-libs-dev mailing list