On Tue, 4 Nov 2025 09:17:27 GMT, Igor Rudenko <[email protected]> wrote:

> Add more precise message for IndexOutOfBoundsException in MemorySegment

src/java.base/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java 
line 433:

> 431: 
> 432:     private IndexOutOfBoundsException outOfBoundException(long offset, 
> long length) {
> 433:         return new IndexOutOfBoundsException(String.format("Out of bound 
> access on segment %s; " +

The new message looks ok, but note that this message is also reused by the 
`asSlice` methods. If we want to clarify the messages, perhaps we should think 
about rearranging the code a bit?

Related note: this is also why the routine that check OOB access needs to worry 
about `length` being zero -- because that's a valid value for `asSlice` (but 
not for access).

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28124#discussion_r2489522721

Reply via email to