On Wed, 28 Apr 2021 20:40:49 GMT, Mandy Chung <mch...@openjdk.org> wrote:
> > To be clear - by aliasing you mean when the @CallerSensitive implementation > > is called with invokeinterface - so, e.g. doing > > `MethodHandles.lookup().findVirtual(CLinker.class, ...)` right? > > Yes. The caller would be java.base if it's invoked via method handle. I just did a test: public class TestLookup { public static void main(String[] args) throws Throwable { MethodHandle handle = MethodHandles.lookup().findVirtual(CLinker.class, "downcallHandle", MethodType.methodType(MethodHandle.class, Addressable.class, MethodType.class, FunctionDescriptor.class)); CLinker linker = CLinker.getInstance(); handle.invoke(linker, MemoryAddress.NULL, MethodType.methodType(void.class), FunctionDescriptor.ofVoid()); } } this fails as expected when the handle is invoked. To test I had to disable the check on CLinker.getInstance - otherwise that would have always throw anyway. Also, on IllegalCaller vs. IllegalAccess - looking more, I think our impl throws IllegalCaller - now that was done because IllegalAccess is a checked exception and we don't want a checked exception here - but the option is called "enableNativeAccess" - is that still ok? ------------- PR: https://git.openjdk.java.net/jdk/pull/3699