Setting foreign.restricted to permit doesn't work
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Thu Apr 23 21:14:14 UTC 2020
This is as expected. The property was always intended to be an opt-in -
e.g. a replacement for a command line flag. Because of an issue in the
implementation, it was possible to bypass the flag and set the property
in a static initializer. Now the implementation correctly reads the
value of the property at VM startup.
In short - you need the command line flag.
Maurizio
On 23/04/2020 22:05, Ty Young wrote:
> Setting "foreign.restricted" to "permit":
>
>
> System.setProperty("foreign.restricted", "permit");
>
>
> fails on the latest source builds. This is before any unsafe
> operations in my JavaFX application or even my "Test" runnable class
> for bindings. Call trace:
>
>
> Caused by: java.lang.IllegalAccessError: Illegal access to restricted
> foreign method: MemorySegment.ofNativeRestricted ; system property
> 'foreign.restricted' is set to 'deny'
> at
> jdk.incubator.foreign/jdk.internal.foreign.Utils.throwIllegalAccessError(Utils.java:99)
> at
> jdk.incubator.foreign/jdk.internal.foreign.Utils.checkRestrictedAccess(Utils.java:84)
> at
> jdk.incubator.foreign/jdk.incubator.foreign.MemorySegment.ofNativeRestricted(MemorySegment.java:540)
> at
> org.goliath.crosspoint/org.goliath.crosspoint.abstracts.ThreadSafeNativeNumber.<init>(ThreadSafeNativeNumber.java:20)
> at
> org.goliath.crosspoint/org.goliath.crosspoint.abstracts.NativeNumber.<init>(NativeNumber.java:66)
> at
> org.goliath.crosspoint/org.goliath.crosspoint.numbers.NativeLong.<init>(NativeLong.java:11)
>
>
>
More information about the panama-dev
mailing list