Update to .find(String) api in loader
This commit is contained in:
parent
0094634818
commit
36f1685718
1 changed files with 3 additions and 2 deletions
|
|
@ -10,6 +10,8 @@ import java.lang.foreign.*;
|
||||||
*/
|
*/
|
||||||
public class Loader {
|
public class Loader {
|
||||||
|
|
||||||
|
static SymbolLookup lookup = Linker.nativeLinker().defaultLookup().or(SymbolLookup.loaderLookup());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a library from a given absolute file path.
|
* Loads a library from a given absolute file path.
|
||||||
*
|
*
|
||||||
|
|
@ -37,7 +39,6 @@ public class Loader {
|
||||||
* @param symbol The name of the symbol to load from a library.
|
* @param symbol The name of the symbol to load from a library.
|
||||||
*/
|
*/
|
||||||
public static MemorySegment findSymbol(String symbol) {
|
public static MemorySegment findSymbol(String symbol) {
|
||||||
return Linker.nativeLinker().defaultLookup().lookup(symbol)
|
return lookup.find(symbol).orElse(null);
|
||||||
.orElseGet(() -> SymbolLookup.loaderLookup().lookup(symbol).orElse(null));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue