Skip to content

Commit 65085c1

Browse files
dkocherdbwiddis
authored andcommitted
Try all frameworks paths regardless of file exist check.
> 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]>
1 parent 22dc037 commit 65085c1

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Bug Fixes
2626
* [#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).
2727
* [#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).
2828
* [#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).
29+
* [#1216](https://github.com/java-native-access/jna/pull/1216): Failure loading frameworks on macOS 11 - [@dkocher](https://github.com/dkocher).
2930

3031
Release 5.5.0
3132
=============

src/com/sun/jna/NativeLibrary.java

+17-5
Original file line numberDiff line numberDiff line change
@@ -242,18 +242,30 @@ else if (Platform.isLinux() || Platform.isFreeBSD()) {
242242
}
243243
// Search framework libraries on OS X
244244
else if (Platform.isMac() && !libraryName.endsWith(".dylib")) {
245-
LOG.log(DEBUG_LOAD_LEVEL, "Looking for matching frameworks");
246-
libraryPath = matchFramework(libraryName);
247-
if (libraryPath != null) {
245+
if (System.getProperty("os.version").compareTo("10.16") >= 0) {
248246
try {
249-
LOG.log(DEBUG_LOAD_LEVEL, "Trying " + libraryPath);
250-
handle = Native.open(libraryPath, openFlags);
247+
LOG.log(DEBUG_LOAD_LEVEL, "Trying " + libraryName);
248+
handle = Native.open(libraryName, openFlags);
251249
}
252250
catch(UnsatisfiedLinkError e2) {
253251
LOG.log(DEBUG_LOAD_LEVEL, "Loading failed with message: " + e2.getMessage());
254252
exceptions.add(e2);
255253
}
256254
}
255+
else {
256+
LOG.log(DEBUG_LOAD_LEVEL, "Looking for matching frameworks");
257+
libraryPath = matchFramework(libraryName);
258+
if (libraryPath != null) {
259+
try {
260+
LOG.log(DEBUG_LOAD_LEVEL, "Trying " + libraryPath);
261+
handle = Native.open(libraryPath, openFlags);
262+
}
263+
catch(UnsatisfiedLinkError e2) {
264+
LOG.log(DEBUG_LOAD_LEVEL, "Loading failed with message: " + e2.getMessage());
265+
exceptions.add(e2);
266+
}
267+
}
268+
}
257269
}
258270
// Try the same library with a "lib" prefix
259271
else if (Platform.isWindows() && !isAbsolutePath) {

0 commit comments

Comments
 (0)