Java 17 bug (?) on Windows with MemorySegment.asSlice and offset =

erel at eth.gl erel at eth.gl
Thu May 12 12:48:40 UTC 2022


Thank you!
The power of 2 workaround works fine with the test project. I'm now testing it with the full project.

Erel

-----Original Message-----
From: Maurizio Cimadamore <maurizio.cimadamore at oracle.com> 
Sent: Thursday, 12 May 2022 14:24
To: erel at eth.gl; panama-dev at openjdk.java.net
Subject: Re: Java 17 bug (?) on Windows with MemorySegment.asSlice and offset =


On 12/05/2022 12:19, Maurizio Cimadamore wrote:
> One thing I noticed is that using file sizes that are a power of two 
> will get rid of errors.

The reason this works, I think, is that, in those cases the truncated value is exactly zero,

 From the specifciation of MapViewOfFile:

https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-mapviewoffile

```
If this parameter is 0 (zero), the mapping extends from the specified offset to the end of the file mapping.
```

So, I think that can be used as a valid workaround, at least in case you want to create a memory region that has the full size of the memory mapping.

Maurizio







More information about the panama-dev mailing list