"Arne Vajhøj" wrote in message
news:4fb96bd5$0$283$1472...@news.sunsite.dk...
On 5/17/2012 9:09 AM, Skybuck Flying wrote:
> My hypothesis that a human being cannot write 10 lines of code without
> making a mistake has been confirmed by either oracle or google or both
> depending on what you believe ;)
>
> The lawsuit apperently mentions these 9 lines of code:
>
> "
> private static void rangeCheck(int arrayLen, int fromIndex, int toIndex) {
> if (fromIndex > toIndex)
> throw new IllegalArgumentException("fromIndex(" + fromIndex +
> ") > toIndex(" + toIndex+")");
> if (fromIndex < 0)
> throw new ArrayIndexOutOfBoundsException(fromIndex);
> if (toIndex > arrayLen)
> throw new ArrayIndexOutOfBoundsException(toIndex);
> }
> "
>
> There is at least 1 major bug in it:
>
> toIndex could equal arrayLen which would still be out of bounds assuming
> zero-index-based arrays.
>
> So for example if the array length is 100, then toIndex is valid for
> range 0 to 99.
>
> And therefore the exception should be raised for equalness to arrayLen
> as well.
>
> So the correct code should probably have been ">=" instead of just ">".
>
> Except if some special outside code assumes that it's ok... I don't know
> where this routine is being used... but by itself it would be flawed.
>
> Also fromIndex could also still go out of range past arrayLen this is
> also not checked.
>
> So this code seems highly buggy and does somewhat prove that it was
> copied ?!
>
> It's a bit unlikely that two programmers make the exact same dumb
> mistake ! ;)
"
The definition of a bug in code is when the code does not
do what it is supposed to do.
In this case the code does exactly what it is supposed to do
(according to the documentation).
So no bug.
May I suggest that you try reading the docs for a method
so you know what it is supposed to do before you claim that it
contains a bug.
Arne
"
No not really, just because the documentation says that "red is now blue"
doesn't make it alright.
There are certain concepts such as range which non-java programmers are used
too.
If java wants to be taken seriously by me then it better take concepts like
range seriously.
I don't take java seriously.
Bye,
Skybuck.