[foreign-preview] RFR: 8281412: MemorySegment::map should live in FileChannel [v2]

Maurizio Cimadamore mcimadamore at openjdk.java.net
Thu Mar 10 15:57:13 UTC 2022


On Thu, 10 Mar 2022 14:48:28 GMT, Julia Boes <jboes at openjdk.org> wrote:

>> This change moves the factory for mapped memory segments to `FileChannel`, as a new instance method `map`, which moves it closer to the existing `FileChannel::map` that returns a `MappedByteBuffer`.  
>> 
>> Tests are adjusted accordingly and a new test for custom file channels (that do/don't override the method) is added.
>
> Julia Boes has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains three commits:
> 
>  - Merge branch 'foreign-preview' into filechannel-mapAsMemorySegment
>  - let caller close the file channel
>  - update docs and tests and add custom file channel test

test/micro/org/openjdk/bench/java/lang/foreign/LoopOverNonConstantMapped.java line 98:

> 96:             ((MappedByteBuffer)byteBuffer).force();
> 97:         }
> 98:         FileChannel fileChannel = FileChannel.open(tempPath, StandardOpenOption.READ, StandardOpenOption.WRITE);

This should be closed in a tearDown method?

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

PR: https://git.openjdk.java.net/panama-foreign/pull/668


More information about the panama-dev mailing list