mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8314592: Add shortcut to SymbolLookup::find
Reviewed-by: jvernee, prr
This commit is contained in:
parent
15190816f7
commit
e923dfe4c5
22 changed files with 151 additions and 63 deletions
|
@ -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}.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue