Fix UnsupportedOperationException on Windows in JNI* loaders#38
Merged
luhenry merged 1 commit intoluhenry:masterfrom Mar 19, 2026
Merged
Conversation
On Windows (NTFS), Files.createTempFile with POSIX file attributes throws:
UnsupportedOperationException: 'posix:permissions' not supported as initial attribute
This crash prevents JNIBLAS, JNILAPACK, and JNIARPACK from loading on any
Windows JVM, silently falling back to the pure-Java implementation.
Fix: guard the POSIX attribute with a FileSystems.getDefault() check, which
returns an empty attribute array on non-POSIX filesystems (Windows/NTFS).
Also add Windows os.name normalisation ("windows") and .dll extension to
match the existing macOS pattern.
Affected files: JNIBLAS.java, JNILAPACK.java, JNIARPACK.java
Owner
|
I’m surprised this works even with the change given that it’s still missing the native JNI shim that sits between the Java code and the native library (the jni.c files for each of blas, lapack, arpack). Would you be interested in adding support for Windows on CI as well? I can always ask Claude otherwise. |
Contributor
Author
|
I compiled the native shim for my testing. Although Happy to help out if I can ... |
Owner
|
Let's merge it as-is for now, and we can work on having the native wrapper in a follow up PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Windows (NTFS),
JNIBLAS,JNILAPACK, andJNIARPACKall crash during initialisation with:This is thrown by
Files.createTempFile(prefix, suffix, PosixFilePermissions.asFileAttribute(...))because NTFS does not support POSIX file attributes. The exception is caught by theInstanceBuilderfallback chain, so on Windows the JNI native backend silently never loads and every caller fallsback to the pure-Java implementation.
Root cause
Three places in the code unconditionally pass a POSIX
FileAttributetoFiles.createTempFile:blas/src/main/java/dev/ludovic/netlib/blas/JNIBLAS.javalapack/src/main/java/dev/ludovic/netlib/lapack/JNILAPACK.javaarpack/src/main/java/dev/ludovic/netlib/arpack/JNIARPACK.javaFix
Guard the attribute with a
FileSystems.getDefault().supportedFileAttributeViews().contains("posix")check — the same portable idiom used elsewhere in the JDK ecosystem. On non-POSIX filesystems (Windows/NTFS) this returns an emptyFileAttribute<?>[], whichFiles.createTempFileaccepts fine.Also adds the existing macOS pattern of
os.namenormalisation and.dllextension for Windows, so the correct resource pathresources/native/windows-amd64/libnetlibblasjni.dllis resolved when a Windows native DLL is bundled in the JAR.Testing
Verified on Windows 11 / MSYS2 / JVM 21 with Breeze 2.1.0:
JNIBLAS: 'posix:permissions' not supported as initial attribute→ falls back to VECTORAPIBLASINFO: Using dev.ludovic.netlib.blas.JNIBLAS→ native OpenBLAS loadedRelates to #20.