On Tue, 5 Jan 2021 15:44:50 GMT, Alan Bateman <al...@openjdk.org> wrote:
>> Hi, >> this patch fixes an oversight where the address() method in >> FileChannelImpl.Unmapper does not take into account the value of >> `pagePosition` - this leads to a situation in which, effectively, the >> specified offset when mapping the segment is ignored by the runtime (because >> base address will always be aligned to some known quantity - which is >> OS/platform dependent). >> >> To test this I had to break open into FileChannelImpl and ready the >> granularity. > > test/jdk/java/foreign/TestByteBuffer.java line 28: > >> 26: * @modules java.base/sun.nio.ch >> 27: * jdk.incubator.foreign/jdk.internal.foreign >> 28: * @run testng/othervm --illegal-access=permit >> -Dforeign.restricted=permit TestByteBuffer > > Can you change java.base/sun.nio.ch to java.base/sun.nio.ch:+open instead? > That would avoid the --illegal-access=permit. I am not sure if a test like this is really needed. The alignment is pageSize on Linux and some arbitrary value (65536) on Windows. If you have some test file that writes like a few bytes (1, 2, 3, 4,...) To a file and then maps it with offsets other than zero, you just have to get the first byte and compare it to offset. ------------- PR: https://git.openjdk.java.net/jdk16/pull/84