Setting foreign.restricted to permit doesn't work
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Thu Apr 23 21:29:14 UTC 2020
On 23/04/2020 22:24, Ty Young wrote:
>
> On 4/23/20 4:14 PM, Maurizio Cimadamore wrote:
>> 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.
>
>
> The MemorySegment.ofNativeRestricted does not mention this currently.
> Could extra clarification be added?
I guess this will probably change few times during the code review I
just posted for integrating what we have into jdk/jdk :-) - I'll keep
the suggestion in mind.
>
>
> What is the runtime argument? --foreign-restricted=permit?
-Dforeign.restricted=permit
Maurizio
>
>
>>
>> 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