On Wed, 21 May 2025 13:53:15 GMT, Jaikiran Pai <j...@openjdk.org> wrote:

>> This PR proposes to use ` JavaNioAccess::getBufferAdress` rather than 
>> `DirectBuffer::address` in the package `java.util.zip` so that `Buffer` 
>> instances backed by `MemorySegment` instances can be used.
>> 
>> This PR passes tier1, tier2, and tier3 tests on multiple platforms and 
>> configurations.
>
> src/java.base/share/classes/java/util/zip/Adler32.java line 102:
> 
>> 100:             NIO_ACCESS.acquireSession(buffer);
>> 101:             try {
>> 102:                 adler = updateByteBuffer(adler, 
>> NIO_ACCESS.getBufferAddress(buffer), pos, rem);
> 
> Hello Per, from what I can see in the implementation of 
> `NIO_ACCESS.getBufferAddress(...)` it merely returns `buffer.address` 
> https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/nio/Buffer.java#L862.
>  So if I understand this change correctly, what we are proposing here is that 
> we want to avoid the additional checks (checks related to `MemorySegment` 
> that can fail?) that are there in the `DirectBuffer.address()` method 
> implementation? Is that what this change is addressing?

All methods in the API that accept a ByteBuffer and access it as DirectBuffer 
should have been changed to use the 
acquireSession/getBufferAddress/releaseSession. Several were missed, I think 
because we didn't have enough tests to exercise the views.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25321#discussion_r2100500374

Reply via email to