On Wed, 11 Mar 2026 22:25:09 GMT, Phil Race <[email protected]> wrote:
>> src/java.desktop/share/classes/java/awt/image/DataBuffer.java line 553:
>>
>>> 551: if ((i < 0) || ((offset + i) < i)) {
>>> 552: throw new ArrayIndexOutOfBoundsException("Index cannot be
>>> negative : " + i);
>>> 553: }
>>
>> The second part ensures `((offset + i) >= 0)`, doesn't it?
>>
>> If the offset is negative, the exception could be confusing… because the
>> reported index in the message will be positive.
>
>> The second part ensures `((offset + i) >= 0)`, doesn't it?
>
> Once we've ensured i >= 0, yes
>
>> If the offset is negative, the exception could be confusing… because the
>> reported index in the message will be positive.
>
> I was trying to be succinct. I can split the test
Yeah, I'm on the fence here. I like it to be succinct.
But I would be utterly confused if I get an exception saying `Index cannot be
negative : 1` if the offset is -2 for example.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/29766#discussion_r2927695320