Setting foreign.restricted to permit doesn't work
Ty Young
youngty1997 at gmail.com
Thu Apr 23 21:46:17 UTC 2020
On 4/23/20 4:43 PM, Ty Young wrote:
>
> On 4/23/20 4:29 PM, Maurizio Cimadamore wrote:
>>
>> 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
>
>
> OK, that works.
>
>
> Next question: what's going on with MemoryAddress handles? Presumably
> you need to do:
>
>
> private static final VarHandle POINTER_HANDLE =
> MemoryHandles.varHandle(LONG_HANDLE, ByteOrder.nativeOrder());
correction: POINTER_HANDLE = MemoryHandles.asAddressVarHandle(LONG_HANDLE);
>
>
> To do what you could before. Is this correct and Is this because of
> all the new fancy methods added to MethodHandles? It surely can't be
> for type safety since VarHandles has none.
>
>
>
>
>>
>> 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