On Tue, 2 Dec 2025 13:10:09 GMT, Igor Rudenko <[email protected]> wrote:

>> Logic for creating IndexOutOfBoundsException in MemorySegment is reworked:
>> - separate logic of checking bounds and constructing exception messages for 
>> both `access` and `slice` cases 
>> - idea presented in 
>> [JDK-8288534](https://bugs.openjdk.org/browse/JDK-8288534) slightly reworked 
>> with preservation of the original approach
>
> Igor Rudenko has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Improvements according to reviewer's advices

I like the new approach!

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

> 419:     @ForceInline
> 420:     private void checkBounds(long offset, long length) {
> 421:         if (length > 0) {

Note: if we know we're not coming from a slice operation, we can just drop the 
if... so I wonder if we could split the impl in two to remove extra branches in 
the access case?

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

Marked as reviewed by mcimadamore (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/28124#pullrequestreview-3531359065
PR Review Comment: https://git.openjdk.org/jdk/pull/28124#discussion_r2582188436

Reply via email to