[foreign-abi] RFR: 8237585: Dismantle ForeignUnsafe

Maurizio Cimadamore mcimadamore at openjdk.java.net
Thu Mar 19 15:49:48 UTC 2020


On Thu, 19 Mar 2020 15:17:57 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

> Hi,
> 
> This is a redo of the earlier patch to dismantle ForeignUnsafe. It replaces ForeignUnsafe with the Foreign interface,
> and the InternalForeign implementation of that interface.
> This PR removes the need to pass --add-exports to make ForeignUnsafe accessible, and replaces it with a runtime check
> on the `jdk.incubator.foreign.Foreign` system property, which is checked when calling `Foreign::getInstance`. The
> `Foreign` object returned from that method acts as an access token for accessing native interop functionality. The
> SystemABI::getInstance factory has also been moved to Foreign, along with the methods that were previously found in
> ForeignUnsafe. All have now been made non-static.  I've updated the tests and also removed the SysV ABI
> `jdk.internal.foreign.NativeInvoker.FASTPATH` which was no longer being used.  Jorn

Looks good. As we were discussing offline, we will need to evaluate as to whether this organization of the API points
is the one that makes the most sense, but in the meantime I think is a much-needed change because: (a) it brings
foreign unsafe functionality out in the public API where developers can see it (b) replaces the module-based hiding
mechanism which is hard to workaround in IDEs and (c) puts SystemABI on same footing with other potentially unsafe
functionalities.

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

Marked as reviewed by mcimadamore (Committer).

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


More information about the panama-dev mailing list