[foreign-memaccess] [Rev 01] RFR: JDK-8243284: Remove Foreign class
Maurizio Cimadamore
mcimadamore at openjdk.java.net
Tue Apr 21 21:19:06 UTC 2020
> The Foreign class is currently used for 3 methods:
>
> * withSize, which takes an unchecked address and gives it a size
> * asUnconfined, which takes an existing segment and turns it into an unconfined segment
> * asMallocSegment, which takes an unchecked address and converts that into a segment which can be closed, and where
> closed is mapped into "free"
>
> This patch replaces all these with this method:
>
> static MemorySegment ofNativeUnsafe(MemoryAddress addr, long bytesSize, Thread owner, AutoCloseable cleanup, Object
> attachment)
> Which is then moved directly into MemorySegment - so that we can garbage-collect the Foreign class.
>
> I've also made some changes on the JDK property - new name is simply "jdk.foreign" and I now made sure that it cannot
> be bypassed with a simple static initializer.
Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:
* simplified API to take Runnable instead of AutoCloseable
* renamed all occurrences of "unsafe" with "restricted" (e.g. as in "restricted foreign")
* cleaned up the code which performs the restricted access check
-------------
Changes:
- all: https://git.openjdk.java.net/panama-foreign/pull/122/files
- new: https://git.openjdk.java.net/panama-foreign/pull/122/files/286c8d07..10b7929a
Webrevs:
- full: https://webrevs.openjdk.java.net/panama-foreign/122/webrev.01
- incr: https://webrevs.openjdk.java.net/panama-foreign/122/webrev.00-01
Stats: 59 lines in 7 files changed: 1 ins; 28 del; 30 mod
Patch: https://git.openjdk.java.net/panama-foreign/pull/122.diff
Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/122/head:pull/122
PR: https://git.openjdk.java.net/panama-foreign/pull/122
More information about the panama-dev
mailing list