Skip to content

Define NativeLibraries.load so java.nio.file works on macOS - #16

Merged
atgreen merged 1 commit into
atgreen:masterfrom
burinc:fix/macos-native-library-load
Oct 18, 2026
Merged

atgreen merged 1 commit into
atgreen:masterfrom
burinc:fix/macos-native-library-load

Conversation

@burinc

@burinc burinc commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

On macOS, the first use of java.nio.file signals UNDEFINED-FUNCTION for the native NativeLibraries.load. That includes MessageDigest.getInstance, since Security reads its master file through Path.of. UnixNativeDispatcher.<clinit> calls BootLoader.loadLibrary("nio"), and on macOS 11+ ClassLoaderHelper.loadLibraryOnlyIfPresent() is false, so the JDK calls load without checking for the file. Linux checks for the file first and never gets that far.

OpenLDK's natives are Lisp, so there is no library to load. load now returns false, which the JDK treats as an absent library, the same as on Linux.

On macOS arm64 (JDK 25.0.2), make check-regression goes from 485 to 492 core passes, the baseline: aaa/h005, gcj/md5test and gcj/shatest now pass, and nothing regresses. The new aaa/digest.java checks an MD5 digest. Unit tests and ocicl lint match master. Not run on Linux.

OpenLDK didn't define the native NativeLibraries.load, so on macOS the
first BootLoader.loadLibrary("nio") signalled UNDEFINED-FUNCTION. That
is reached from the first use of java.nio.file (FileSystems.getDefault
initializes UnixNativeDispatcher) and from MessageDigest.getInstance,
since java.security.Security reads its master file through Path.of.

Only macOS gets there. NativeLibraries skips a library file that isn't
present only when ClassLoaderHelper.loadLibraryOnlyIfPresent() is true,
and on macOS 11 and later it is false because of dyld's shared cache, so
load is called without checking for the file.

OpenLDK's natives are Lisp functions, so there is no library to load:
return false, which the JDK treats as an absent library and
BootLoader.loadLibrary ignores, as on Linux. aaa/digest.java checks an
MD5 digest.
@burinc burinc changed the title Report NativeLibraries.load as not loaded, so java.nio.file and MessageDigest work on macOS Define NativeLibraries.load so java.nio.file works on macOS Oct 14, 2026
burinc added a commit to jlt-commons/jolt-openldk that referenced this pull request Oct 14, 2026
@atgreen atgreen closed this in 8eb6d0e Oct 18, 2026
@atgreen
atgreen merged commit 8eb6d0e into atgreen:master Oct 18, 2026
atgreen added a commit that referenced this pull request Oct 18, 2026
PRs #16, #17 and #18 each added a testsuite case (aaa/digest, aaa/zlib,
aaa/instant).  check-regression.sh only fails on lost passes and new
failures, so a new test is not actually enforced until it is in the
baseline.  Core suites now 501 expected passes, up from 492; no test
changed state.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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