On Wed, 4 May 2022 16:47:28 GMT, ExE Boss <d...@openjdk.java.net> 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 57 commits: >> >> - Merge branch 'master' into foreign-preview >> - Update >> src/java.base/share/classes/jdk/internal/misc/X-ScopedMemoryAccess.java.template >> >> Co-authored-by: ExE Boss <3889017+exe-b...@users.noreply.github.com> >> - Tweak support for Linker lookup >> Improve javadoc of SymbolLookup >> - Tweak Addressable javadoc >> - Downcall and upcall tests use wrong layout which is missing some trailing >> padding >> - Simplify libraryLookup impl >> - Address CSR comments >> - Merge branch 'master' into foreign-preview >> - Add ValueLayout changes >> - Tweak support for array element var handle >> - ... and 47 more: >> https://git.openjdk.java.net/jdk/compare/af1ee1cc...41d055ab > > src/java.base/share/classes/java/lang/foreign/SymbolLookup.java line 153: > >> 151: static SymbolLookup loaderLookup() { >> 152: Class<?> caller = Reflection.getCallerClass(); >> 153: ClassLoader loader = >> Objects.requireNonNull(caller.getClassLoader()); > > Shouldn’t this be changed to throw `IllegalCallerException` instead of > throwing `NullPointerException` when the `caller`’s `ClassLoader` is > `null`[^1] or when `caller` itself is `null`[^2]? > > [^1]: This happens when `caller` is on the bootstrap classpath. > [^2]: This happens when `SymbolLookup.loaderLookup()` is called by native > code and no **Java** code is on the call stack. 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). ------------- PR: https://git.openjdk.java.net/jdk/pull/7888