RFR: 8287244: Add bound check in indexed memory access var handle [v2]

Maurizio Cimadamore mcimadamore at openjdk.java.net
Tue May 24 18:15:45 UTC 2022


On Tue, 24 May 2022 18:02:50 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Sorry i misread the text, we are talking about the same thing. I think it would be clearer to refer `x_i` being in the range of `0` (inclusive) and `b_i` (exclusive), otherwise an .... is thrown. That way in subsequent doc on other methods in matches with `B`, which is exclusive.
>
> yes, but that seems to affect this statement:
> 
> 
> `0 <= x_i <= b_i, where 0 <= i <= n`, or IndexOutOfBoundsException is thrown.
> 
> So we can replace with
> 
> 
> 0 <= x_i < b_i, where 1 <= i <= n`, or IndexOutOfBoundsException is thrown.

> Sorry i misread the text, we are talking about the same thing. I think it would be clearer to refer `x_i` being in the range of `0` (inclusive) and `b_i` (exclusive), otherwise an .... is thrown. That way in subsequent doc on other methods in matches with `B`, which is exclusive.

I apologize too - I misread your original question and thought it was about the use of ceilDiv :-) - anyway, at least that prodded me to come up with an example that explains why the logic is the way it is :-)

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

PR: https://git.openjdk.java.net/jdk/pull/8868


More information about the core-libs-dev mailing list