On Tue, 3 May 2022 10:40:02 GMT, Maurizio Cimadamore <[email protected]> wrote:
>> This PR contains the API and implementation changes for JEP-424 [1]. A more >> detailed description of such changes, to avoid repetitions during the review >> process, is included as a separate comment. >> >> [1] - https://openjdk.java.net/jeps/424 > > 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 <[email protected]> > - 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 116: > 114: * Linker nativeLinker = Linker.nativeLinker(); > 115: * SymbolLookup stdlib = nativeLinker.defaultLookup(); > 116: * MemorySegment malloc = stdlib.lookup("malloc"); This should be: Suggestion: * Optional<MemorySegment> malloc = stdlib.lookup("malloc"); or Suggestion: * MemorySegment malloc = stdlib.lookup("malloc").orElseThrow(); 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. ------------- PR: https://git.openjdk.java.net/jdk/pull/7888
