RFR  Mistake in documentation of ArrayList#removeRange
mike.duigou at oracle.com
Sat Mar 15 03:45:43 UTC 2014
On Mar 14 2014, at 05:14 , Ivan Gerasimov <ivan.gerasimov at oracle.com> wrote:
> On 14.03.2014 16:02, David Holmes wrote:
>> On 14/03/2014 9:19 PM, Ivan Gerasimov wrote:
>>> Thanks Peter for the comments.
>>> On 14.03.2014 14:53, Peter Levart wrote:
>>>> On 03/14/2014 08:05 AM, Ivan Gerasimov wrote:
>>>>> One thing I noticed is that some methods I mentioned above
>>>>> (List.subList(), Arrays.sort(), etc) throw IllegalArgumentException
>>>>> when fromIndex > toIndex, not IndexOutOfBoundException.
>>>>> Wouldn't it be more correct to adopt this into removeRange() too?
>>>> The question is, what exception should be thrown for removeRange(0,
>>>> -1) then... The order of checks matters and should be specified if two
>>>> kinds of exceptions are thrown...
>>> In my opinion, the order of the checks should match the order of the
>>> listed exceptions in the spec.
The @throws tags aren't ordered. The javadoc tool is free to re-order them (such as alphabetization or grouping by super class).
Specifying the exception behaviour to this degree seems like vast overspecification. What's the value other than to someone writing a validation test who might have to catch or expect both exceptions? In real user code it doesn't seem important which particular exception is thrown. In either case the fix that must be applied by the programmer is likely the same in either case.
More information about the core-libs-dev