Not all compilers emit RuntimeExceptions into the .class file to begin with. Reflection data is not guaranteed to be the same between two compilers, even if you DO declare the RuntimeExceptions, because compilers have the right to optimize for size and omit wasting the space on the useless declaration information. Therefore, code relying on the declared RuntimeExceptions returned by reflection is just asking for problems.
David Holmes wrote:
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 [EMAIL PROTECTED]
but some people may start declaring the runtime exceptions just to inherit the doc comments.
David Holmes
_______________________________________________ Classpath mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/classpath
-- Someday, I might put a cute statement here.
Eric Blake [EMAIL PROTECTED]
_______________________________________________ Classpath mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/classpath