-
Notifications
You must be signed in to change notification settings - Fork 157
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
Added feature: Check if library exists without loading it #229
Conversation
This gives callers a way to determine if the system will find the library with the passed in name in the system library default locations in addition to the optional passed in additional paths, without having to try to the load the library, so that callers are aware of missing libraries early. This fixes jnr#228
Hmm, something's not right on Darwin. I tested the new code on a macOS Big Sur 11.2.3 x86_64 and it's not as I expected, namely my assumption, system property I installed JACK which then created
But here's the funny thing... If I add Jack jack = LibraryLoader.loadLibrary(Jack.class, new HashMap<>(), "jack");
public interface Jack {
int jack_activate(PointerByReference client);
} It works! This mostly makes sense to me but indicates that Apple's own documentation labels some expected default locations for dylibs similar to most Unixes I believe, see this for some kind of Unix documentation regarding locations, though generally they are as I put in (my discussion](#225) previously:
I still haven't even touched Windows. Anyway, this is all to say, things are a little more complicated than I thought and I still have more to check and test before I'd call this "Cross-platform ready", but at least GNU/Linux (the most important OS) is done I think. |
…ader.DefaultLibPaths.PATHS and added more functionality to the class so that it adds expected Unix lib paths. Also added Platform.libraryLocations which will most likely replace Platform.canFindLibrary because Platform.libraryLocations is much more useful. Still need to look into using Windows and write some better tests
and slightly modified behavior of LibraryLoader.DefaultLibPaths.PATHS such that it will not contain duplicate paths AND will also add all paths from ld.so.conf even if they don't exist because they could later exist and validation is done elsewhere anyway.
After further exploration, it really was just a matter of slightly tweaking and improving The class is now called The Anyway that's probably the final commit to add this functionality to the API, officially this is the addition of I also added tests to verify expected behavior. Hope this helps, cheers 😊 |
I will review this for inclusion in 2.2.3 today! |
I like this. It does not change the existing logic substantially but clarifies the search order and provides a way to query where the library was found. Ship it! |
@headius cheers man! |
@basshelal The 2.2.3 release and all other downstream JNR library releases should be live shortly! Thanks again! |
This gives callers a way to determine if the system will find the library with the passed in name in the system library default locations in addition to the optional passed in additional paths, without having to try to the load the library, so that callers are aware of missing libraries early.
This fixes #228