MemorySegment.mapFromPath vs FileChannel.map

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Fri Apr 24 09:55:59 UTC 2020


Hi,
as Uwe said, this is easily fixable, as the underlying machinery takes 
an offset as well.

I'm not sure I see a lot of value in putting MapMode first vs. last - on 
the one hand you have the consistency with the FileChannel API, which 
you bring up, but on the other hand you also have consistency with the 
rest of the memory segment API whose factories are all "size first".

Maurizio

On 24/04/2020 09:21, Philippe Marschall wrote:
> Hello
>
> I noted a difference between MemorySegment.mapFromPath and
> FileChannel.map. MemorySegment.mapFromPath only allows to specify a
> length but not an offset. Is this intentional or an oversight? Only
> having the ability to map a subsgement from the start of the file seems
> strange. Especially given that FileChannelImpl.mapInternal already
> offers an offset.
>
> Also the FileChannel methods use the map mode as the first argument
> whereas MemorySegment uses it as the last.
>
> Cheers
> Philippe


More information about the panama-dev mailing list