[foreign-preview] RFR: 8281412: MemorySegment::map should live in FileChannel [v3]
Maurizio Cimadamore
mcimadamore at openjdk.java.net
Fri Mar 11 10:23:09 UTC 2022
On Fri, 11 Mar 2022 08:50:42 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 incrementally with one additional commit since the last revision:
>
> address PR comment: close file channel
Some javadoc tweaks are probably required.
src/java.base/share/classes/java/nio/channels/FileChannel.java line 1029:
> 1027: * {@linkplain MemorySession#ownerThread() owning} {@code session}.
> 1028: *
> 1029: * @throws UnsupportedOperationException
I think the javadoc might have gotten out of sync with that of FileChannel::map -> ByteBuffer. In the ByteBuffer map method there is no SecurityException anymore, and there is a NonReadableChannelException and NonWriteableChannelException which can also be thrown. I would suspect that this method can throw exactly the same exceptions in exactly the same ways. These exception ate triiggered by `checkMode` which is called by `mapInternal`, so I'd suspect that they can occur with the memory segment map too.
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/668
More information about the panama-dev
mailing list