[foreign-memaccess] RFR: JDK-8242051: Clarify difference between checked and unchecked addresses
Maurizio Cimadamore
mcimadamore at openjdk.java.net
Thu Apr 2 17:55:16 UTC 2020
While most memory addresses are associated with a segment, addresses coming from native code, or those created from
scratch (e.g. MemoryAddress::ofLong) do not have an associated segment.
This patch addresses this problem by having unchecked memory addresses returning`null` on MemoryAddress::segment().
Similarly, the MemoryAddress::offset method has been renamed to `segmentOffset` and now throws UOE if called on an
unchecked address.
This makes the API cleaner: it is only possible to dereference those addresses which have an associated segment. I've
tweaked the javadoc to convey that message more clearly.
-------------
Commit messages:
- * Tweaked API to return null if segment attached to MemoryAddress is nothing segment
Changes: https://git.openjdk.java.net/panama-foreign/pull/90/files
Webrev: https://webrevs.openjdk.java.net/panama-foreign/90/webrev.00
Issue: https://bugs.openjdk.java.net/browse/JDK-JDK-8242051
Stats: 50 lines in 6 files changed: 23 ins; 2 del; 25 mod
Patch: https://git.openjdk.java.net/panama-foreign/pull/90.diff
Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/90/head:pull/90
PR: https://git.openjdk.java.net/panama-foreign/pull/90
More information about the panama-dev
mailing list