On Tue, 20 May 2025 16:10:07 GMT, Per Minborg <pminb...@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
>> 
>> This PR passes tier1, tier2, and tier3 tests on multiple platforms and 
>> configurations.
>
> Per Minborg has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Update after comments

test/jdk/java/nio/channels/AsynchronousFileChannel/Basic.java line 583:

> 581:             }
> 582:             default -> throw new InternalError("Should not reach here");
> 583:         };

Suggestion:

        return switch (rand.nextInt(3)) {
            case 0  -> ByteBuffer.allocateDirect(buf.length)
                                 .put(buf)
                                 .flip();
            case 1  -> ByteBuffer.wrap(buf);
            case 2  -> Arena.ofAuto()
                            .allocate(buf.length)
                            .asByteBuffer()
                            .put(buf)
                            .flip();
            default -> throw new InternalError("Should not reach here");
        };

ByteBuffer supports chain programming style, so we can simplify it to this

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

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

Reply via email to