RFR: 8358537: (bf) JavaNioAccess::getBufferAddress bypasses direct buffer MemorySession state check
Brian Burkhalter
bpb at openjdk.org
Tue Jun 3 22:35:15 UTC 2025
On Tue, 3 Jun 2025 21:39:54 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
>> Add package-scope `long java.nio.Buffer::address()` to simply return the value of the `address` instance variable; use this method in `JavaNioAccess::getBufferAddress`.
>
> test/jdk/java/nio/channels/etc/MemorySegments.java line 61:
>
>> 59: */
>> 60: static Stream<Supplier<Arena>> arenaSuppliers() {
>> 61: return Stream.of(Arena::global, Arena::ofAuto, Arena::ofConfined);
>
> Why is using a shared arena causing the UOE to be thrown? I'd think that would be triggered by the use of heap buffers, but shared arena is for off-heap memory.
I thin it's running into this method in DirectBufferX:
public long address() {
MemorySessionImpl session = session();
if (session != null) {
if (session.ownerThread() == null && session.isCloseable()) {
throw new UnsupportedOperationException("ByteBuffer derived from closeable shared sessions not supported");
}
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25631#discussion_r2125050873
More information about the nio-dev
mailing list