Skip to content
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

Should usage of SymbolLookup.loaderLookup() be opt-in? #81

Open
maloewe-ona opened this issue Feb 19, 2025 · 1 comment
Open

Should usage of SymbolLookup.loaderLookup() be opt-in? #81

maloewe-ona opened this issue Feb 19, 2025 · 1 comment

Comments

@maloewe-ona
Copy link

maloewe-ona commented Feb 19, 2025

In v0.24.1 for #59 (f1f42c1) the library loading was changed to use SymbolLookup.loaderLookup() as fallback if SymbolLookup.libraryLookup(library, ...) fails.

The disadvantage is that when users don't actually want to use SymbolLookup.loaderLookup(), the library loading silently fails and afterwards they encounter cryptic "UnsatisfiedLinkError: unresolved symbol: ts_..." errors.
(probably related: #80)

Now that #61 added support for custom library loading, would it make sense to make usage of SymbolLookup.loaderLookup() a deliberate opt-in decision of the user, by implementing a NativeLibraryLookup? For example:

public class LoaderLibLookup implements NativeLibraryLookup {
    @Override
    public SymbolLookup get(Arena arena) {
        return SymbolLookup.loaderLookup();
    }
}

Then for all users who don't want to rely on this, if no NativeLibraryLookup implementation has been registered and SymbolLookup.libraryLookup(...) fails, library loading could fail fast.

In that case the package-info.java documentation would have to be updated again, mentioning this possibility to use SymbolLookup.loaderLookup() with NativeLibraryLookup.

This is just an idea though; the disadvantage would be that for users who do want to use SymbolLookup.loaderLookup() it would be a bit more cumbersome.

@ObserverOfTime
Copy link
Member

I'd rather keep the fallback in place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants