Changes to RandomAccessFile in jdk9
Alan Bateman
Alan.Bateman at oracle.com
Sun Apr 22 07:53:50 UTC 2018
I've re-read the discussion on this issue from 2016, both in
JDK-8168628, and the mails here.
Looking at it now, I don't think RanomAccessFile.setLength should have
been changed. Instead, the changes should have been limited to
FileChannel.map to force disk space for the desired mapped region to be
allocated first (irrespective of whether the mapping causes the file to
be extended or not). This will also fix other cases with FileChannel
that were missed. I'll create a bug for this.
Reading Ismael's mail then it will have no impact on the "memory mapped
index file" case. If a sparse index file is memory mapped with
FileChannel.map then the disk space for the mapped region will be
allocated. If the "log segment files" are sparse then they will continue
to be so unless they are memory-mapped.
-Alan
More information about the nio-dev
mailing list