google / conscrypt

Conscrypt is a Java Security Provider that implements parts of the Java Cryptography Extension and Java Secure Socket Extension.
Apache License 2.0
1.28k stars 274 forks source link

java.lang.UnsatisfiedLinkError due to System Language #1115

Open Berikai opened 1 year ago

Berikai commented 1 year ago
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:61)
Caused by: java.lang.UnsatisfiedLinkError: no conscrypt_openjdk_jni-wındows-x86_64 in java.library.path: C:\Program Files\Java\jdk-17\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files\Microsoft\jdk-17.0.6.10-hotspot\bin;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\ia32\compiler;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\nodejs\;C:\ProgramData\chocolatey\bin;C:\Users\Berkay\AppData\Local\Microsoft\WindowsApps;C:\Users\Berkay\AppData\Roaming\npm;.
        at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2429)
        at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:818)
        at java.base/java.lang.System.loadLibrary(System.java:1989)
        at org.conscrypt.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:54)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.conscrypt.NativeLibraryLoader$1.run(NativeLibraryLoader.java:297)
        at org.conscrypt.NativeLibraryLoader$1.run(NativeLibraryLoader.java:289)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
        at org.conscrypt.NativeLibraryLoader.loadLibraryFromHelperClassloader(NativeLibraryLoader.java:289)
        at org.conscrypt.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:262)
        at org.conscrypt.NativeLibraryLoader.load(NativeLibraryLoader.java:162)
        at org.conscrypt.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java:106)

As you can see, Caused by: java.lang.UnsatisfiedLinkError: no conscrypt_openjdk_jni-wındows-x86_64 this should be written as conscrypt_openjdk_jni-windows-x86_64 (with i, not ı)

This issue appears when my system locale is Turkish. I tested this in both Linux and Windows operating systems. It doesn't appear when system locale is English (United States).

kruton commented 1 year ago

Yes, that's a bug. For those addressing it, it might be worth adding an custom errorprone check to make sure toLowerCase() is not used without a locale argument. I believe PMD already has that kind of check.

Berikai commented 1 year ago

Thanks for the clarification.

I've solved my problem by calling Locale.setDefault(Locale) method.

Locale.setDefault(new Locale("en", "US"));

For those who want to achieve this with non-programmatic way can set user.country user.language properties of JVM. It can be passed as arguments like below example.

-Duser.country=US -Duser.language=en

prbprbprb commented 1 year ago

Ironically this looks like it's due to the HostProperties class for the OpenJDK build, which is intended to normalise machine/arch consistently with Maven osdetector plugin, is locale-unaware in several places.

Definite bug.