commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Dudziak <>
Subject Re: [lang] enhanced version of Class.forName
Date Tue, 06 Sep 2005 14:58:03 GMT
On 9/6/05, James Carman <> wrote:

> Do you think we need to go through the trouble of throwing an
> IllegalArgumentException if it's not a well-formed class name (starts with
> character, blah blah blah)?  Or, can we just let it throw a
> ClassNotFoundException after doing as much as we can with the string that's
> passed in (i.e. transforming it into the proper format)?

I usually prefer to use different exceptions for different causes,
because makes handling them a lot easier.
Ie. a NullPointerException is perfectly fine if the supplied type spec
is null. Likewise a IllegalArgumentException seems fine if the type
spec is not a valid type declaration (ie. only brackets, different
number of opening and closing brackets, etc.). If it is syntactically
correct, then a ClassNotFoundException seems fine though.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message