RFR: 8346657: Improve out of bounds exception messages for MemorySegments [v9]

Igor Rudenko duke at openjdk.org
Tue Nov 18 12:38:13 UTC 2025


On Tue, 18 Nov 2025 12:16:15 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Igor Rudenko has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   improvements according to reviewer comments
>
> src/java.base/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java line 413:
> 
>> 411:     private void checkBounds(long offset, long length, BoundPolicy policy) {
>> 412:         if (length > 0) {
>> 413:             Preconditions.checkIndex(offset, this.length - length + 1, new BoundsCheckHandler(this, policy));
> 
> This is a very very hot path. Allocating here is gonna have negative effect, especially when this code cannot be inlined (in which case the allocation can't be scalar replaced).

Thank you for pointing this out, I believe we can move on with this solution if and only if the escape analysis eliminates instance creation. I'll run benchmarks you mentioned in order to check if it's so.

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

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


More information about the core-libs-dev mailing list