On Thursday 26 September 2002 03:28 pm, Berin Loritsch wrote: > Steve Downey wrote: > > On Thursday 26 September 2002 02:02 pm, Henri Yandell wrote: > >>On Thu, 26 Sep 2002, Berin Loritsch wrote: > >>>>Its probably a pity that we didn't agree a uniform approach to this, > >>>>but its too late now. The priority is to document what we have > >>>>correctly. > >>>> > >>>>Stephen > >> > >>I don't think this is a problem. The too late now. If we go from > >>quiet->NPE it's a problem, but if we go from NPE->quiet behaviour then > >>it's merely seen as strengthening the API, no one can or should be > >>dependent on the NPE behaviour. > >> > >>Hen > > > > Actually, I strongly disagree with that. Going from NPE to quiet is a > > major change in behavior. Nulls will be treated as values, when they are > > not. > > > > And I wouldn't call it a strengthening of the API. It's a weakening of > > the preconditions. > > > > In any case, as I'm looking through right now, at least a few of the > > methods that claim not to thow NPEs, do. > > My point is not to remove the throwing of exceptions, but to throw an > exception that is more meaningful. The NPE is automatically thrown by > the system if you try to perform an action on a null reference--AKA the > C++ pointer error analogy. That is why I prefer to use > IllegalArgumentExceptions instead. We are not weakening preconditions, > but we are letting the user of the API know where the problem is (in > the arguments passed in).
But that's not what we're discussing. It's not whether NPE or IAE should be thrown, but whether an exception should be thrown at all. And in cases where detection of a null is trivial, I agree that IAE is more meaningful than NPE. Even though Sun didn't do things that way. Later today (hopefully) I'll post a documentation patch that will, with any luck, make things clearer. -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
