Skip to content

fix: automatically load library when using loaderLookup #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,14 @@ private static SymbolLookup findLibrary(Arena arena) {
try {
var library = System.mapLibraryName("tree-sitter");
return SymbolLookup.libraryLookup(library, arena);
} catch (IllegalArgumentException e) {
return SymbolLookup.loaderLookup();
} catch (IllegalArgumentException ex1) {
try {
System.loadLibrary("tree-sitter");
return SymbolLookup.loaderLookup();
} catch (UnsatisfiedLinkError ex2) {
ex1.addSuppressed(ex2);
throw ex1;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@
* SymbolLookup.libraryLookup(String, Arena)}.
* </li>
* <li>
* The libraries can be loaded manually by calling
* {@link java.lang.System#loadLibrary(String) System.loadLibrary(String)},
* if the library is installed in {@systemProperty java.library.path},
* or {@link java.lang.System#load(String) System.load(String)}.
* If the libraries are installed in {@systemProperty java.library.path} instead,
* they will be loaded automatically by {@link java.lang.foreign.SymbolLookup#loaderLookup()
* SymbolLookup.loaderLookup()}.
* </li>
* <li>
* The libraries can be loaded manually by registering a custom implementation of
Expand Down
Loading