On Wed, 4 May 2022 23:29:53 GMT, Maurizio Cimadamore <mcimadam...@openjdk.org> 
wrote:

>> Good points. Regarding `ClassLoader` being null, I think we can still return 
>> something using the `BootLoader`'s `NativeLibraries` object - that would 
>> allow this method to be called internally. @mlchung Can you please confirm?
>> 
>> As for the caller sensitive having no real caller (e.g. because method is 
>> called directly from native code), I think we should add a check in 
>> `Reflection::ensureNativeAccess`. Few weeks ago I verified that adding such 
>> a check does not compromise upcall stub created via the Linker interface 
>> (e.g. a Java upcall might require to perform restricted operations - but 
>> those operation always happen inside the upcall MH, which is always 
>> associated with some class).
>
> Another option would be to treat calls to `ensureNativeAccess` with `null` 
> caller class as coming from unnamed module.

Looking deeper, `System::loadLibrary` seems to search the boot loader libraries 
when invoked with a `null` caller class, so replicating that behavior should be 
safe.

-------------

PR: https://git.openjdk.java.net/jdk/pull/7888

Reply via email to