Skip to content

Commit

Permalink
Try all frameworks paths regardless of file exist check.
Browse files Browse the repository at this point in the history
> New in macOS Big Sur 11 beta, the system ships with a built-in dynamic linker cache of all system-provided libraries. As part of this change, copies of dynamic libraries are no longer present on the filesystem. Code that attempts to check for dynamic library presence by looking for a file at a path or enumerating a directory will fail. Instead, check for library presence by attempting to dlopen() the path, which will correctly check for the library in the cache. (62986286)

Fix #1215.

Signed-off-by: David Kocher <[email protected]>
  • Loading branch information
dkocher authored and dbwiddis committed Jul 1, 2020
1 parent 22dc037 commit 65085c1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Bug Fixes
* [#1183](https://github.com/java-native-access/jna/pull/1183): `c.s.j.p.win32.WinDef.CHARByReference#getValue` should only read one byte - [@dbwiddis](https://github.com/dbwiddis).
* [#1184](https://github.com/java-native-access/jna/pull/1184): `c.s.j.p.win32.WinDef.ULONGLONG` should always be 8 bytes - [@dbwiddis](https://github.com/dbwiddis).
* [#1196](https://github.com/java-native-access/jna/pull/1196): `c.s.j.p.win32.WinNT.LARGE_INTEGER` needs to populate both union fields - [@dbwiddis](https://github.com/dbwiddis).
* [#1216](https://github.com/java-native-access/jna/pull/1216): Failure loading frameworks on macOS 11 - [@dkocher](https://github.com/dkocher).

Release 5.5.0
=============
Expand Down
22 changes: 17 additions & 5 deletions src/com/sun/jna/NativeLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,18 +242,30 @@ else if (Platform.isLinux() || Platform.isFreeBSD()) {
}
// Search framework libraries on OS X
else if (Platform.isMac() && !libraryName.endsWith(".dylib")) {
LOG.log(DEBUG_LOAD_LEVEL, "Looking for matching frameworks");
libraryPath = matchFramework(libraryName);
if (libraryPath != null) {
if (System.getProperty("os.version").compareTo("10.16") >= 0) {
try {
LOG.log(DEBUG_LOAD_LEVEL, "Trying " + libraryPath);
handle = Native.open(libraryPath, openFlags);
LOG.log(DEBUG_LOAD_LEVEL, "Trying " + libraryName);
handle = Native.open(libraryName, openFlags);
}
catch(UnsatisfiedLinkError e2) {
LOG.log(DEBUG_LOAD_LEVEL, "Loading failed with message: " + e2.getMessage());
exceptions.add(e2);
}
}
else {
LOG.log(DEBUG_LOAD_LEVEL, "Looking for matching frameworks");
libraryPath = matchFramework(libraryName);
if (libraryPath != null) {
try {
LOG.log(DEBUG_LOAD_LEVEL, "Trying " + libraryPath);
handle = Native.open(libraryPath, openFlags);
}
catch(UnsatisfiedLinkError e2) {
LOG.log(DEBUG_LOAD_LEVEL, "Loading failed with message: " + e2.getMessage());
exceptions.add(e2);
}
}
}
}
// Try the same library with a "lib" prefix
else if (Platform.isWindows() && !isAbsolutePath) {
Expand Down

0 comments on commit 65085c1

Please sign in to comment.