Native image fails to load a DLL from a path that contains non-ASCII characters... or from a path that contains the ~N tilde notation.
Describe the issue
This is a Windows only issue.
I have an app that uses JNA. JNA initially loads a DLL (jnidispatch.dll) after extracting it into a temporary folder that looks like this: C:\Users\<username>\AppData\Local\Temp\jna--187459531\jna11031635164979162837.dll
If the \<username> contains non-ASCII characters (e.g. José), or if, in addition to containing non-ASCII characters, the username is too long (Alejandría) and Windows uses the \~N tilde notation (C:\Users\Alejan~1\AppData\...), the GraalVM native image fails loading the DLL:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't load library: C:\Users\Alejan~1\AppData\Local\Temp\jna--187459531\jna11031635164979162837.dll
at org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibraryAbsolute(NativeLibrarySupport.java:100)
at java.base@21.0.1/java.lang.ClassLoader.loadLibrary(ClassLoader.java:114)
at java.base@21.0.1/java.lang.Runtime.load0(Runtime.java:852)
at java.base@21.0.1/java.lang.System.load(System.java:2021)
at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:1045)
at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:1015)
at com.sun.jna.Native.<clinit>(Native.java:221)
at mousemaster.ExtendedKernel32.<clinit>(ExtendedKernel32.java:7)
Steps to reproduce the issue
To reproduce that problem, I just had to give JNA (-Djna.tmpdir) a path containing the \~N tilde notation.
Native image fails to load a DLL from a path that contains non-ASCII characters... or from a path that contains the ~N tilde notation.
Describe the issue
This is a Windows only issue.
I have an app that uses JNA. JNA initially loads a DLL (jnidispatch.dll) after extracting it into a temporary folder that looks like this: C:\Users\<username>\AppData\Local\Temp\jna--187459531\jna11031635164979162837.dll
If the \<username> contains non-ASCII characters (e.g. José), or if, in addition to containing non-ASCII characters, the username is too long (Alejandría) and Windows uses the \~N tilde notation (C:\Users\Alejan~1\AppData\...), the GraalVM native image fails loading the DLL:
Steps to reproduce the issue
To reproduce that problem, I just had to give JNA (-Djna.tmpdir) a path containing the \~N tilde notation.
Describe GraalVM and your environment:
More details
This works (non-native version running with graalvm-jdk-21.0.1+12.1):
This does not work (native image):
This works (native image still, \~N tilde notation still, but only ASCII characters: Alejandro):