Skip to content

Include DragonFlyBSD in library loading fallback paths#1727

Merged
dbwiddis merged 1 commit into
java-native-access:masterfrom
dbwiddis:fix/dragonflybsd-library-loading
May 27, 2026
Merged

Include DragonFlyBSD in library loading fallback paths#1727
dbwiddis merged 1 commit into
java-native-access:masterfrom
dbwiddis:fix/dragonflybsd-library-loading

Conversation

@dbwiddis
Copy link
Copy Markdown
Contributor

Summary

DragonFlyBSD platform support was added in #1593 but NativeLibrary was not updated to include DragonFlyBSD in the fallback paths that FreeBSD already uses.

Problem

When loading libc (or any library by short name) on DragonFlyBSD, the following fails with UnsatisfiedLinkError / NoClassDefFoundError:

  • The versioned .so fallback (matchLibrary()) only triggers for Linux and FreeBSD
  • The special-case libc loading from the current process only covers Linux, FreeBSD, and AIX
  • The mapSharedLibraryName() handling for .so files only covers Linux and FreeBSD
  • The 64-bit library search path only includes Linux, FreeBSD, Solaris, and kFreeBSD

Fix

Add Platform.isDragonFlyBSD() to all four locations in NativeLibrary.java where Platform.isFreeBSD() is checked. DragonFlyBSD is a FreeBSD derivative and uses the same library naming conventions.

Testing

Discovered while porting OSHI to DragonFlyBSD. Verified that the workaround (using "c" instead of "libc") resolves the loading issue, confirming the root cause is in these fallback paths.

@dbwiddis dbwiddis force-pushed the fix/dragonflybsd-library-loading branch from 11d5ced to 85b7567 Compare May 26, 2026 17:04
DragonFlyBSD platform support was added in java-native-access#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.
@dbwiddis dbwiddis force-pushed the fix/dragonflybsd-library-loading branch from 85b7567 to 08628c0 Compare May 26, 2026 17:17
Copy link
Copy Markdown
Member

@matthiasblaesing matthiasblaesing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me. Thanks

@dbwiddis dbwiddis merged commit f670868 into java-native-access:master May 27, 2026
12 checks passed
@dbwiddis dbwiddis deleted the fix/dragonflybsd-library-loading branch May 27, 2026 18:01
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

Successfully merging this pull request may close these issues.

2 participants