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

Alan Bateman alanb at openjdk.org
Tue May 20 12:27:52 UTC 2025


On Tue, 20 May 2025 10:51:13 GMT, Per Minborg <pminborg at openjdk.org> wrote:

> This PR proposes to use  `JavaNioAccess::getBufferAdress` rather than `DirectBuffer::address` so that `Buffer` instances backed by MemorySegment instances can be used in classes that were not covered by https://github.com/openjdk/jdk/pull/25321
> 
> In some of the cases, this is not strictly needed as the internal cache in `sun.nio.ch.Util#getTemporaryDirectBuffer` is (currently) only returning Buffers that are not backed by a `MemorySegment`. Also, we now always acquire/release buffer sessions before interacting with memory. Again, this is not always needed for temporary direct buffers but provides a consistent handling of buffers at a minimal cost.
> 
> This PR passes tier1, tier2, and tier3 tests on multiple platforms and configurations.

We need to audit the tests for the APIs that take a byte buffer to ensure that we have tests to exercise these APIs with buffers that are views on a memory segment. That would help identify any bugs. 

The temporary buffer cache is internal so I think better to separate from this JBS issue and PR as these cases cannot be views on a memory segment. Future work to re-implement the temporary buffer cache can re-visit this.

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

PR Comment: https://git.openjdk.org/jdk/pull/25324#issuecomment-2894215287


More information about the net-dev mailing list