RFR: 8333886: Explicitly specify that asSlice and reinterpret return a memory segment backed by the same region of memory.

Jorn Vernee jvernee at openjdk.org
Tue Jun 11 10:14:12 UTC 2024


On Tue, 11 Jun 2024 09:18:23 GMT, Per Minborg <pminborg at openjdk.org> wrote:

> If a segment is reinterpreted to be larger than this segment, then the extra memory is not a part of this segment's backing part.

Another way to think about this is: a segment's backing region can be larger or smaller than the bounds specified by the segment itself. Though, in most cases they are the same. For example, If we allocate 10 bytes of memory in native code, and return it to the Java side, I'd argue that the backing region of the memory segment we get back is still 10 bytes in size, even though the `byteSize()` of the memory segment is `0`. `reinterpret` can be used to adjust the size of the _segment_, but it doesn't change the size of the underlying memory region, which remains 10 bytes.

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

PR Comment: https://git.openjdk.org/jdk/pull/19633#issuecomment-2160359044


More information about the core-libs-dev mailing list