I quite disagree with that. AIOOBE, NPE and IAE are all indicating some incorrect situation and I don't think any applications would expect a particular behavior in these situations. Moreover, this difference is much smaller than the one we already accepted.
Also, checking the indexes is more performance-intensive, than checking for null. Also, passing a null parameter is "more incorrect" I think, than passing a wrong index, as it violates the method specification. In other words, I'm voting for checking nulls first and indexes second. However, if you're sure and insist - ok, I'll correct the patch. Vasily -----Original Message----- From: Alexei Zakharov [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 26, 2006 11:32 PM To: [email protected] Subject: Re: Compatibility or non-bug question In general looks Ok to me. The only exception is that IMHO we should throw IndexOutOfBoundException before IAE in HARMONY-2525 in order to be "closer" to RI. Thanks, 2006/12/26, Zakharov, Vasily M <[EMAIL PROTECTED]>: > > Ok, so let's make the decisisions. > Below are my propositions, any objections? > > http://issues.apache.org/jira/browse/HARMONY-1024: > Leave it as is, close as Won't Fix. > > http://issues.apache.org/jira/browse/HARMONY-1171: > Sure, checking FLAT context limitations is necessary, it's clearly a > bug. > Also, checking for null name is important, though RI doesn't do it. > > http://issues.apache.org/jira/browse/HARMONY-1232: > It's pretty clear that neither 'name', nor 'attrs' can be null - > otherwise getName() and getAttributes() methods would return null, > explicitly violating the spec - and that's what RI does. So this issue > is clearly a non-bug diff and must not be fixed to fit RI behavior. So > this issue could be closed as Won't Fix. > > But in fact, Harmony throws IAE only if 'name' is null, 'attrs' is not > checked. If 'attrs' is null, object is created but NPE is thrown if, for > example, toString() is called for it. > > So my proposition is: > 1. Add checking if 'attrs' is null and throwing IAE if it is. > 2. Add tests verifying that IAE is thrown if either 'name' or 'attrs' is > null. > > http://issues.apache.org/jira/browse/HARMONY-2525: > > Throwing InvalidNameException for null component is not a good idea, as > that exception is clearly intended for other situations. The good > solution would be to throw IllegalArgumentException. > > Anyway, this issue has to be moved to "Non-bug differences from RI" > category, as RI doesn't check the component for null at all - and is > wrong in that. > > Vasily > > > -----Original Message----- > From: Andrew Zhang [mailto:[EMAIL PROTECTED] > Sent: Monday, December 25, 2006 4:34 AM > To: [email protected] > Subject: Re: Compatibility or non-bug question > > On 12/24/06, Zakharov, Vasily M <[EMAIL PROTECTED]> wrote: > > > > > > Can't remember, I may be wrong. > > > > Well, what would be our policy on this point? > > > > If the documentation describes the parameter as "non-null", or null > > value is clearly unacceptable for the method functionality, what > should > > we throw if null is passed, NullPointerException or > > IllegalArgumentException? > > > It depends on RI and spec as described in our exception thrown > compatibility > guideline. :-) > > Vasily > > > > > > -----Original Message----- > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Nathan > > Beyer > > Sent: Sunday, December 24, 2006 5:42 AM > > To: [email protected] > > Subject: Re: Compatibility or non-bug question > > > > On 12/23/06, Zakharov, Vasily M <[EMAIL PROTECTED]> wrote: > > > > > > I've read in some clever article :) that NPE is a way to react on > > > un-predicted situation and it should never be thrown explicitly. And > > > IAE, in contrary, is there exactly for explicit handling of > incorrect > > > argument situations. > > > > Can you provide an actual reference to this article? I'm not familiar > > with any such guideline or design consideration. > > > > Regardless, there's nothing wrong explicitly throwing NPE. > > > > -Nathan > > > > > > > > So if we need to check the argument and throw exception manually - > it > > > should be IAE with "argument is null" comment string, my vote. :) > > > > > > Vasily > > > > > > > > > -----Original Message----- > > > From: Alexei Zakharov [mailto:[EMAIL PROTECTED] > > > Sent: Thursday, December 21, 2006 12:30 PM > > > To: [email protected] > > > Subject: Re: Compatibility or non-bug question > > > > > > > Why NPE and not IllegalArgumentException? > > > > If doc says "non-null", the latter may also be appropriate... > > > > > > IMHO NullPointerException emphasizes the fact that argument was set > to > > > *null* value. However, I think IllegalArgumentException is also Ok. > > > > > > Thanks, > > > > > > 2006/12/20, Zakharov, Vasily M <[EMAIL PROTECTED]>: > > > > > > > > Thanks Alexei! > > > > > > > > > IMHO it is ok to throw NullPointerException here and file > > > Non-Bug-Diff > > > > JIRA. > > > > > > > > Why NPE and not IllegalArgumentException? > > > > If doc says "non-null", the latter may also be appropriate... > > > > > > > > Vasily > > > > > > > > > > > > -----Original Message----- > > > > From: Alexei Zakharov [mailto:[EMAIL PROTECTED] > > > > Sent: Wednesday, December 20, 2006 4:57 PM > > > > To: [email protected] > > > > Subject: Re: Compatibility or non-bug question > > > > > > > > Hi, > > > > > > > > > http://issues.apache.org/jira/browse/HARMONY-1024 > > > > > > > > So RI allows creation of the Binding with null name. I don't see > > much > > > > sence in such object. How can it be used? For what? Moreover, we > > have > > > > a non-null spec requirement. So IMHO it is ok to throw > > > > NullPointerException here and file Non-Bug-Diff JIRA. > > > > > > > > > http://issues.apache.org/jira/browse/HARMONY-2525 > > > > > > > > The same thing here. The only exception is that IMHO test3 from > this > > > > JIRA is valid. Why not to throw IndexOutOfBoundsException before > > > > NullPointerException? > > > > > > > > Regards, > > > > > > > > > > > > > > > > > > > > 2006/12/17, Zakharov, Vasily M <[EMAIL PROTECTED]>: > > > > > > > > > > Well, that's better than nothing. :) > > > > > > > > > > In fact, those two bugs I've mentioned are the ones I'm most > > > > interested > > > > > in right now: > > > > > > > > > > http://issues.apache.org/jira/browse/HARMONY-1024 > > > > > http://issues.apache.org/jira/browse/HARMONY-2525 > > > > > > > > > > What to you think we should do to them? > > > > > > > > > > Thank you. > > > > > > > > > > Vasily > > > > > > > > > > > > > > > -----Original Message----- > > > > > From: Alexey Petrenko [mailto:[EMAIL PROTECTED] > > > > > Sent: Saturday, December 16, 2006 7:48 AM > > > > > To: [email protected] > > > > > Subject: Re: Compatibility or non-bug question > > > > > > > > > > We have a compatibility guideline [1]. > > > > > And according this guideline we should discuss cases like yours > > one > > > by > > > > > one. > > > > > > > > > > SY, Alexey > > > > > > > > > > [1] > > http://harmony.apache.org/subcomponents/classlibrary/compat.html > > > > > > > > > > 2006/12/16, Zakharov, Vasily M <[EMAIL PROTECTED]>: > > > > > > Hi, all, > > > > > > > > > > > > I'm now trying to investigate and fix some trivial bugs, but > I'm > > > not > > > > > > sure which way to fix them to. > > > > > > > > > > > > There're multiple situations where RI, say, doesn't throw > > > exception > > > > > and > > > > > > Harmony does throw, and throwing an exception in that > situation > > > > looks > > > > > > good and logical. > > > > > > > > > > > > In other words, the question is, what is a compatibility bug > > (that > > > > > needs > > > > > > to be fixed to match RI) and what is a non-bug difference. > > > > > > > > > > > > Also, there's a question on non-bug differences. They're not > > bugs, > > > > but > > > > > > what should we do to them? Just close them, if Harmony > behaviour > > > > seems > > > > > > more correct than RI's? Or fix them to match RI though they're > > not > > > > > bugs, > > > > > > to make sure we don't break existing applications? > > > > > > > > > > > > Here are two characteristic examples of uncertainties that > occur > > > > > rather > > > > > > frequently: > > > > > > http://issues.apache.org/jira/browse/HARMONY-1024 > > > > > > http://issues.apache.org/jira/browse/HARMONY-2525 > > > > > > > > > > > > Do we have some, say, policy, or guideline on how issues like > > > these > > > > > > could (or should) be resolved? > > > > > > > > > > > > There're many issues like these, and having a general approach > > > would > > > > > > ease dealing with them... > > > > > > > > > > > > Any opinions? > > > > > > > > > > > > Thank you! -- Alexei Zakharov, Intel ESSD
