RFR: 8357268: Use JavaNioAccess.getBufferAddress rather than DirectBuffer.address() [v7]

Valerie Peng valeriep at openjdk.org
Wed May 21 17:57:53 UTC 2025


On Tue, 20 May 2025 11:01:46 GMT, Per Minborg <pminborg at openjdk.org> wrote:

>> Per Minborg has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Fix copyright year
>
> src/java.base/windows/classes/sun/nio/ch/WindowsAsynchronousFileChannelImpl.java line 459:
> 
>> 457: 
>> 458:             boolean pending = false;
>> 459:             NIO_ACCESS.acquireSession(buf);
> 
> Here, we acquire the session *after* we have obtained the address. This is safe as we do not touch the segment before it is acquired. If a segment is deallocated before we try to acquire the session, an exception will be thrown.

Is there documentation on when sessions should be acquired/released? Is this only for when using MemorySegment? In security area, the bytes are passed to the JNI code which calls the native library to process the bytes and I wonder if sessions should be acquired/released for these.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25324#discussion_r2100870190


More information about the net-dev mailing list