On Wed, 29 Apr 2026 18:11:53 GMT, Sergey Bylokhov <[email protected]> wrote:

>> I don't think we've changed the meaning of size. 
>> Before this PR was begun we had
>> 
>>    /**
>>      * Constructs a byte-based {@code DataBuffer} with a single bank using 
>> the
>>      * specified array, size, and offset.  {@code dataArray} must have at 
>> least
>>      * {@code offset} + {@code size} elements.
>> ...
>> */
>>   public DataBufferByte(byte[] dataArray, int size, int offset){
>> 
>> and
>>    public int getElem(int i) {
>>         return (int)(data[i+offset]) & 0xff;
>>     }   
>>         
>> The constructor docs still say the same now and the getElem() call still 
>> uses [i+offset]
>
> Then the code(and test), and the error message should be updated to follow 
> the spec "0 <= index < size"

I think I see the confusion. 
There's no point adding offset to both sides.
And the constructor already validated offset+size (the bank one even has a 
comment on this!)
So the code was correct (and I'll revert) and the question was about the error 
message.
It should have said too large for offset+size .. or just remove the mention of 
offset.
I'll do the latter. Although removing it from the method that takes a bank 
loses a little bit of info.
I've also added some tests that ensure we can access index=(size-1) with a 
non-zero offset in place

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/29766#discussion_r3164486656

Reply via email to