[foreign-memaccess] RFR: JDK-8249753: Add restricted factory to access everything segment

Maurizio Cimadamore mcimadamore at openjdk.java.net
Mon Jul 20 11:31:08 UTC 2020


This patch adds another restricted factory, namely `MemorySegment::ofRestrictedNative()`. The new factory takes no
arguments and return a segment that has the following characteristics:

* its base address is `MemoryAddress::NULL`
* its size is `Long.MAX_VALUE`
* it is non-closeable
* it is not confined

Note that this is not *exactly* the _everything_ segment, since, at least in principle, addressable space goes up to `2
^ 64 - 1` while `Long::MAX_VALUE` is "only" `2^63 -1`. In other words, there is a possibility for some addresses to
show up as *negative* long values, which will then be rejeced during dereference.

That said, for all intent and purposes, the segment returned by the new factory is a close enough approximation to the
everything segment; we'd prefer to start with that and expand later (with some concrete use cases) rather than adding a
new kind of memory segment which might not be needed.

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

Commit messages:
 - Add 'everything' segment

Changes: https://git.openjdk.java.net/panama-foreign/pull/249/files
 Webrev: https://webrevs.openjdk.java.net/panama-foreign/249/webrev.00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8249753
  Stats: 45 lines in 3 files changed: 45 ins; 0 del; 0 mod
  Patch: https://git.openjdk.java.net/panama-foreign/pull/249.diff
  Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/249/head:pull/249

PR: https://git.openjdk.java.net/panama-foreign/pull/249


More information about the panama-dev mailing list