Closed mymagicpower closed 1 year ago
@mymagicpower I don't think this can be fixed, it's a bug in Java System.load()
function.
I tried the following code, and it failed with Chinese file path:
Path file = Paths.get("asmjit.dll");
String path = file.toAbsolutePath().toString();
System.out.println("Loading file: " + path);
System.load(path);
System.out.println("Loaded file: " + path);
file = Paths.get("张三\\asmjit.dll");
path = file.toAbsolutePath().toString();
System.out.println("Loading file: " + path);
System.load(path);
System.out.println("Loaded file: " + path);
Loading file: C:\source\test\asmjit.dll
Loaded file: C:\source\test\asmjit.dll
Loading file: C:\source\test\张三\asmjit.dll
Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\source\test\??\asmjit.dll: Can't find dependent libraries
at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:384)
at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:228)
at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:170)
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2389)
at java.base/java.lang.Runtime.load0(Runtime.java:755)
at java.base/java.lang.System.load(System.java:1953)
at org.example.Main.main(Main.java:22)
@frankfliu can we add a special character check before System.load command? This will fail regardless of System right? It will provide a better insight on what's going on
We can add a warning if cache directory contains non-ASCII chars. But non-ASCII chars not necessary will always fail.
The problem is CJK Windows native charset is not set to UTF-8, it usually be "GBK", "Shitf-JIS" etc. For most of western language, non-ASCII chars should still work.
Description
For windows environment - chinese username not supported. e.g: C:\Users\张三.djl.ai\pytorch
Expected Behavior
Chinese username should be supported.