[foreign-abi] RFR: 8237585: Dismantle ForeignUnsafe

Paul Sandoz paul.sandoz at oracle.com
Tue Feb 25 17:24:10 UTC 2020


Hi,

I don’t think we should be referencing sun.misc.Unsafe in the documentation of a public API.  It should stand on its own presenting access to the unsafe address pair for double-register addressing.  Any implication that this information can be consumed by sun.misc.Unsafe is coincidental :-)

How is is the address pair intended to be used by the Java caller other than pumping the values into Unsafe methods?

Perhaps with inline types we could model this as an UnsafeMemoryAddress.  Is that possible to do now by appealing to a value-based property in the interim?
(Internally we don’t need to use that.)

—

This is for a longer discussion…. In past times we might have appealed to a security manager to perform such a permission check.  In current times I think we are more talking about checks to safe guard the integrity of the program.  (Unwarranted System.exit calls might also fit into this approach.) 

Paul.


> On Feb 25, 2020, at 7:09 AM, Jorn Vernee <jvernee at openjdk.java.net> wrote:
> 
> Removes ForeignUnsafe, moves `getUnsafeBase` and `getUnsafeAccess` to `MemoryAddress`, and moves `ofNativeUnchecked` to `MemorySegment`.
> 
> I've added a warning about the safety of these methods to the javadoc.
> 
> Use of the methods is guarded by a check against a system property, `jdk.incubator.foreign.permitUnsafeInterop` for the first 2, and `jdk.incubator.foreign.permitUncheckedSegments` for the latter. This needs to be set to `true` when running an application, or otherwise the use of these methods results in an `IllegalAccessError` being thrown.
> 
> I've updated the test accordingly, and also remove the FASTPATH option from the SysV ABI implementation, since it was not actually being used, but still causing the tests to be run multiple times.
> 
> -------------
> 
> Commits:
> - 5c58877a: Slightly touch up javadoc
> - 6abdd478: Remove ForeignUnsafe.java, and move it's method to MemoryAddress and MemorySegment
> 
> Changes: https://git.openjdk.java.net/panama-foreign/pull/31/files
> Webrev: https://webrevs.openjdk.java.net/panama-foreign/31/webrev.00
>  Issue: https://bugs.openjdk.java.net/browse/JDK-8237585
>  Stats: 176 lines in 10 files changed: 78 ins; 91 del; 7 mod
>  Patch: https://git.openjdk.java.net/panama-foreign/pull/31.diff
>  Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/31/head:pull/31
> 
> PR: https://git.openjdk.java.net/panama-foreign/pull/31



More information about the panama-dev mailing list