RFR: 8281089: JavaFX built with VS2019 and jlinked into JDK 11.x fails to start

Kevin Rushforth kcr at openjdk.java.net
Wed Feb 16 16:53:37 UTC 2022


The `javafx.graphics` module has a number of native libraries, including the redistributable Microsoft DLLs on Windows. When running an application using the standalone JavaFX SDK, we load all of the needed DLLs from the SDK `bin` directory and everything works as expected.

When creating the jmods, we currently exclude the Microsoft DLLs from `javafx.graphics.jmod` to avoid the problem described in [JDK-8207015](https://bugs.openjdk.java.net/browse/JDK-8207015) where `jlink` complains about two modules (`java.base` and `javafx.graphics`) deliver the same file(s). That works as long as the set of Microsoft DLLs delivered by the JDK is from the same or newer version of Microsoft Visual Studio. This means that you can't take, for example, JDK 11.0.x and run the latest version of JavaFX, since JDK 11.x uses VS 2017 and JavaFX 15 (and later) uses VS 2019.

Up until now this has just been a minor bug, but we are now at the point where we need to update to VS 2019 for building JavaFX 11.0.15, which means that a jlinked JDK 11.0.X + JavaFX 11.0.15 will no longer work.

This fix is to add the Microsoft DLLs back into `javafx.graphics.jmod` (i.e., stop excluding them at build time), but deliver them in `bin/javafx` so they don't conflict with the ones delivered by the JDK.

The changes are:

1. `build.gradle` - When creating the jmods on Windows, copy all of the DLLs to a javafx sub-directory
2. `NativeLibLoader.java` - in the case of JavaFX modules jlinked into the Java runtime, load the libraries first from `${java.home}` rather than always falling back to `System::loadLibrary`. Most of the changes are just simple refactoring. The additional logic is in the new `libDirForJRT` method.

When running using the SDK or the modules on maven central, there is no change in behavior.

I've tested this on all platforms, including a test of a custom JDK 11.x created with jlink. On a Windows I tested it on a system where a key VS 2019 runtime library was not present in C:\Windows\System32 and it now runs.

-------------

Commit messages:
 - 8281089: JavaFX built with VS2019 and jlinked into JDK 11.x fails to start

Changes: https://git.openjdk.java.net/jfx/pull/734/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jfx&pr=734&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8281089
  Stats: 125 lines in 2 files changed: 74 ins; 39 del; 12 mod
  Patch: https://git.openjdk.java.net/jfx/pull/734.diff
  Fetch: git fetch https://git.openjdk.java.net/jfx pull/734/head:pull/734

PR: https://git.openjdk.java.net/jfx/pull/734


More information about the openjfx-dev mailing list