RFR: 8286637: (fc) Memory mapped regions bigger than 2GB do not work correctly on Windows [v2]

Brian Burkhalter bpb at openjdk.java.net
Thu May 12 23:27:31 UTC 2022


On Thu, 12 May 2022 20:55:47 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> test/jdk/java/nio/channels/FileChannel/LargeMapTest.java line 64:
>> 
>>> 62:         MemorySegment mappedMemorySegment = MemorySegment.mapFile(p, 0,
>>> 63:             p.toFile().length(), FileChannel.MapMode.READ_WRITE,
>>> 64:             ResourceScope.newSharedScope());
>> 
>> Note that I've integrated JEP 424. As a result, you will need to update this test in the following ways:
>> 
>> * replace `jdk.incubator.foreign` with `java.lang.foreign`
>> * add @enablePreview to the test
>> * replace `ResourceScope` with `MemorySession`
>> * the `map` method for segments has moved into `FileChannel`, for constistency
>> 
>> In addition, I think it would be better to use `MemorySession.openImplicit()` as session/scope parameter, since we don't want to call close explicitly.
>
> Would it be worth running the test on all platforms, rather than on windows only? And should we test other size combinations and offsets? For instance, Windows has some tricky code to split size and offset of the mapping - the test in this PR checks that the size is split correctly, but it doesn't check the mapping offset (which the test sets to 0).
> 
> Would be interesting perhaps to add a case which creates the mapping of a 8G file at offset 3G and then starts iterating.

> Note that I've integrated JEP 424. As a result, you will need to update this test in the following ways:
> 
>     * replace `jdk.incubator.foreign` with `java.lang.foreign`
> 
>     * add @enablePreview to the test
> 
>     * replace `ResourceScope` with `MemorySession`
> 
>     * the `map` method for segments has moved into `FileChannel`, for constistency
> 
> 
> In addition, I think it would be better to use `MemorySession.openImplicit()` as session/scope parameter, since we don't want to call close explicitly.

Fixed by commit b5c3b0d9c25d3fcdee88f3e4f2b36c26e0de3d17.

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

PR: https://git.openjdk.java.net/jdk/pull/8686


More information about the nio-dev mailing list