Loading of shared libraries required by JFX
Armin Schrenk
armin.schrenk at skymatic.de
Fri Mar 24 14:43:20 UTC 2023
Just to avoid confusion: Building a custom JRE with jlink with the Azul
Zulu JDK+FX on Windows, the resulting JRE does not have a not have
"/bin/javafx". That bug is either in the Zulu JDK or in jlink itself.
An excerpt from stdout/stderr with Zulu being the build JDK:
//-- general dlls required by jdk --
WARNING: java.lang.UnsatisfiedLinkError: Can't load library: C:\Program
Files\Cryptomator\runtime\bin\javafx\msvcp140_1.dll
Loaded C:\WINDOWS\system32\msvcp140_1.dll from java.library.path
WARNING: java.lang.UnsatisfiedLinkError: Can't load library: C:\Program
Files\Cryptomator\runtime\bin\javafx\msvcp140_2.dll
Loaded C:\WINDOWS\system32\msvcp140_2.dll from java.library.path
//-- jfx specifc dlls --
WARNING: java.lang.UnsatisfiedLinkError: Can't load library: C:\Program
Files\Cryptomator\runtime\bin\javafx\prism_d3d.dll
System.loadLibrary(prism_d3d) succeeded
JavaFX: using com.sun.javafx.tk.quantum.QuantumToolkit
WARNING: java.lang.UnsatisfiedLinkError: Can't load library: C:\Program
Files\Cryptomator\runtime\bin\javafx\glass.dll
System.loadLibrary(glass) succeeded
14:44:49.558 [JavaFX Application Thread] INFO
o.cryptomator.launcher.Cryptomator - JavaFX runtime started after 962ms
WARNING: java.lang.UnsatisfiedLinkError: Can't load library: C:\Program
Files\Cryptomator\runtime\bin\javafx\javafx_font.dll
System.loadLibrary(javafx_font) succeeded
I marked with two comments, which DLLs are in general needed by the JDK
and which are JFX specifc. The build JDK was zulu19.32.15 +FX . As it
can be seen in the excerpt, the JDK DLLs and JFX DLLs are also loaded
differently (Stdout message: "Loaded XXX.dll from java.library.path" vs
"System.loadLibrary(XXX) succeeded"). Looking into NativeLibLoader.java,
those are the third and fourth try of loading a shared lib. While
System.loadLibrary(...) does not have documented load order
(https://docs.oracle.com/en/java/javase/19/docs/api/java.base/java/lang/System.html#loadLibrary(java.lang.String)),
it seems like it also checks "java.home".
This approach (third traverse java.library.path and only on fourth try
use System.loadLib) breaks the application under the following conditions:
* app uses the default "java.library.path" (defaults to %PATH% in Windows)
* %PATH% has a directory, which contains required (aka with the same
name), but outdated DLLs
A user of Cryptomator had a JRE 8 in its path "C:\Program Files
(x86)\Zulu\zulu-8-jre\bin\", which resulted in loading the wrong libs.
If the load order would be to call System.loadLibrary(...) before
traversing "java.library.path", in this application _might_ run. (since
System.loadLibrary(...) lacks documentation about where it looks first
for shared libs this might also depend on the JDK)
> Can you confirm that the JavaFX libraries are in
$JAVA_HOME/bin/javafx and not in $JAVA_HOME/bin?
As mentioned before, this depends on the build JDK. With Zulu JDK+FX,
"bin/javafx/" won't be created and all JFX related shared libs are
inside the "/bin" directory. With Adoptium JDK and additional Gluon
Jmods, "bin/javafx" exists. In my previous mail I linked post in the
zulu dev forum, asking for this behaviour.
In the end, for us the failure cause is clear. What we are asking now
ourself is, what the best fix is:
* use a different JDK (because Zulu might be broken)
* define "java.library.path" (because this might be the convention/spec)
Since JFX has this custom lib loader, we hope to get some suggestion on
this list.
Kind regards,
Armin
Am 23/03/2023 um 00:08 schrieb openjfx-dev-request at openjdk.org:
> Message: 1
> Date: Wed, 22 Mar 2023 10:42:09 -0700
> From: Kevin Rushforth <kevin.rushforth at oracle.com>
> To: openjfx-dev at openjdk.org
> Subject: Re: Loading of shared libraries required by JFX
> Message-ID: <652d96f4-ce1b-27ba-71a4-687d56318c28 at oracle.com>
> Content-Type: text/plain; charset=UTF-8; format=flowed
>
> This seems like a bug to me. Can you provide the output of running with
> "java -Djavafx.verbose=true". That will show how the libraries are being
> loaded. Depending on what the verbose output shows, we can file a bug to
> investigate fixing it. As for your question about the first item in the
> search order, I think that comment is wrong (I'll take a closer look),
> since it should be using that first step for a custom jlinked JDK with
> the JavaFX modules.
>
> Can you confirm that the JavaFX libraries are in $JAVA_HOME/bin/javafx
> and not in $JAVA_HOME/bin?
>
> -- Kevin
More information about the openjfx-dev
mailing list