[foreign-memaccess+abi] RFR: 8307461: Linker::nativeLinker should not be restricted [v2]
Maurizio Cimadamore
mcimadamore at openjdk.org
Mon May 8 09:02:51 UTC 2023
On Sat, 6 May 2023 08:00:32 GMT, ExE Boss <duke at openjdk.org> wrote:
>> Maurizio Cimadamore has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains two commits:
>>
>> - Merge branch 'foreign-memaccess+abi' into restricted_linker
>> - Initial push
>
> src/java.base/share/classes/jdk/internal/foreign/abi/AbstractLinker.java line 83:
>
>> 81: @CallerSensitive
>> 82: public final MethodHandle downcallHandle(FunctionDescriptor function, Option... options) {
>> 83: Reflection.ensureNativeAccess(Reflection.getCallerClass(), Linker.class, "downcallHandle");
>
> This needs to use `downcallHandle0` so as to not perform 2 consecutive `Reflection::ensureNativeAccess` calls with the second having a caller class parameter value of `jdk.internal.foreign.abi.AbstractLinker`.
> Suggestion:
>
> return downcallHandle0(function, options).bindTo(symbol);
> }
>
> @Override
> @CallerSensitive
> public final MethodHandle downcallHandle(FunctionDescriptor function, Option... options) {
> Reflection.ensureNativeAccess(Reflection.getCallerClass(), Linker.class, "downcallHandle");
> return downcallHandle0(function, options);
> }
>
> private MethodHandle downcallHandle0(FunctionDescriptor function, Option[] options) {
I agree that would be cleaner - but at the same time, please note that the current code would work correctly as classes in base module are trusted. I will consider the refactoring when moving to mainline.
-------------
PR Review Comment: https://git.openjdk.org/panama-foreign/pull/831#discussion_r1187206682
More information about the panama-dev
mailing list