Skip to content

Commit 85b7567

Browse files
committed
Include DragonFlyBSD in library loading fallback paths
DragonFlyBSD platform support was added in #1593 but the NativeLibrary fallback paths for versioned .so resolution, libc special-case loading, and 64-bit library search paths were not updated to include it. This causes NoClassDefFoundError when loading libc on DragonFlyBSD because the matchLibrary() fallback and the mapSharedLibraryName() handling only trigger for Linux and FreeBSD.
1 parent 0e29d6f commit 85b7567

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Bug Fixes
2323
* [#1722](https://github.com/java-native-access/jna/pull/1722): Fix `Advapi32#RegisterServiceCtrlHandler` using wrong `Handler` type - [@dbwiddis](https://github.com/dbwiddis).
2424
* [#1636](https://github.com/java-native-access/jna/issues/1636): Drop hard dependency on java.lang.SecurityManager/java.security.AccessController - [@matthiasblaesing](https://github.com/matthiasblaesing).
2525
* [#1724](https://github.com/java-native-access/jna/pull/1724): Fix `host_page_size` in `c.s.j.p.mac.SystemB` and `getxattr`/`setxattr`/`listxattr` in `c.s.j.p.mac.XAttr` using `long` instead of pointer-sized types for `size_t`/`ssize_t` parameters - [@dbwiddis](https://github.com/dbwiddis).
26+
* [#1727](https://github.com/java-native-access/jna/pull/1727): Include DragonFlyBSD in `NativeLibrary` versioned library resolution, libc special-case loading, and 64-bit search paths - [@dbwiddis](https://github.com/dbwiddis).
2627

2728
Release 5.18.1
2829
==============

src/com/sun/jna/NativeLibrary.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ private static NativeLibrary loadLibrary(final String libraryName, final Map<Str
245245
exceptions.add(e2);
246246
}
247247
}
248-
else if (Platform.isLinux() || Platform.isFreeBSD()) {
248+
else if (Platform.isLinux() || Platform.isFreeBSD() || Platform.isDragonFlyBSD()) {
249249
//
250250
// Failed to load the library normally - try to match libfoo.so.*
251251
//
@@ -465,7 +465,7 @@ public static final NativeLibrary getInstance(String libraryName, Map<String, ?>
465465

466466
// Use current process to load libraries we know are already
467467
// loaded by the VM to ensure we get the correct version
468-
if ((Platform.isLinux() || Platform.isFreeBSD() || Platform.isAIX())
468+
if ((Platform.isLinux() || Platform.isFreeBSD() || Platform.isDragonFlyBSD() || Platform.isAIX())
469469
&& Platform.C_LIBRARY_NAME.equals(libraryName)) {
470470
libraryName = null;
471471
}
@@ -788,7 +788,7 @@ static String mapSharedLibraryName(String libName) {
788788
}
789789
return name;
790790
}
791-
else if (Platform.isLinux() || Platform.isFreeBSD()) {
791+
else if (Platform.isLinux() || Platform.isFreeBSD() || Platform.isDragonFlyBSD()) {
792792
if (isVersionedName(libName) || libName.endsWith(".so")) {
793793
// A specific version was requested - use as is for search
794794
return libName;
@@ -926,8 +926,8 @@ static double parseVersion(String ver) {
926926
// one when running a 64bit JVM.
927927
//
928928
if (Platform.isLinux() || Platform.isSolaris()
929-
|| Platform.isFreeBSD() || Platform.iskFreeBSD()) {
930-
// Linux & FreeBSD use /usr/lib32, solaris uses /usr/lib/32
929+
|| Platform.isFreeBSD() || Platform.isDragonFlyBSD() || Platform.iskFreeBSD()) {
930+
// Linux, FreeBSD // Linux & FreeBSD use DragonFlyBSD use /usr/lib32, solaris uses /usr/lib/32
931931
archPath = (Platform.isSolaris() ? "/" : "") + Native.POINTER_SIZE * 8;
932932
}
933933
String[] paths = {

0 commit comments

Comments
 (0)