classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Declaring RuntimeExceptions?


From: David Holmes
Subject: RE: Declaring RuntimeExceptions?
Date: Fri, 12 Sep 2003 09:01:41 +1000

Standard practice - as epoused by various books and articles from
various source related to Sun - is to not declare RuntimeExceptions on
a throws clause. Such exceptions should be documented in the javadoc
only.

However, the reflection issue is not something I was aware of. If
indeed reflection returns all declared throwables whether runtime
exceptions or not, then there will be a behavioural difference -
though not one that anybody should ever be relying upon.

This situation is also clouded by the default rules for inheriting
@throws documentation comments, which will only inherit comments for
exceptions that are listed in the throws clause. The way around this
is to not declare the exception but instead to the use @inheritDoc to
force the inheritance of the doc comment eg:

   @throws someRuntimeException address@hidden

but some people may start declaring the runtime exceptions just to
inherit the doc comments.

David Holmes





reply via email to

[Prev in Thread] Current Thread [Next in Thread]