8314592: Add shortcut to SymbolLookup::find

Reviewed-by: jvernee, prr
This commit is contained in:
Per Minborg 2024-04-24 11:56:44 +00:00
parent 15190816f7
commit e923dfe4c5
22 changed files with 151 additions and 63 deletions

View file

@ -100,7 +100,7 @@
* Linker linker = Linker.nativeLinker();
* SymbolLookup stdlib = linker.defaultLookup();
* MethodHandle strlen = linker.downcallHandle(
* stdlib.find("strlen").orElseThrow(),
* stdlib.findOrThrow("strlen"),
* FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)
* );
*
@ -111,7 +111,7 @@
*}
*
* Here, we obtain a {@linkplain java.lang.foreign.Linker#nativeLinker() native linker}
* and we use it to {@linkplain java.lang.foreign.SymbolLookup#find(java.lang.String) look up}
* and we use it to {@linkplain java.lang.foreign.SymbolLookup#findOrThrow(java.lang.String) look up}
* the {@code strlen} function in the standard C library; a <em>downcall method handle</em>
* targeting said function is subsequently
* {@linkplain java.lang.foreign.Linker#downcallHandle(FunctionDescriptor, Linker.Option...) obtained}.