Jeroen Frijters wrote:
David Daney wrote:
We cannot violate the JLS! A method that throws a checked exception
without declaring it is a bug.
Rubbish! There are several ways to throw checked exceptions:
http://weblogs.java.net/blog/crazybob/archive/2004/09/dont_try_this_a.ht
ml
Rubbish does describe how I feel about that blog article.
That was my exact point. Tell me if you disagree with this point:
Point) It is the intent of the JLS (version 2 section 11.2) that methods
only throw checked exceptions that they declare.
The fact that it is possible to design a java implementation that
violates this intent should not be surprising. We are all smart people,
we can make it do pretty much anything we desire.
Because it is directly in conflict with the intent of the JLS, I don't
think we should violate the checked exception rule in order to mimic the
behavior of broken implementations.
The documentation (jdk 1.4.2) of Class.newInstance() says that
InstantiationException is thrown if "... if the instantiation fails for
some other reason." In my book throwing an exception falls under the
catagory of "some other reason"
David Daney.