JDK-8207015 : jlink javafx.graphics on Windows fails: PluginException: Duplicate resources
  • Type: Bug
  • Component: javafx
  • Sub-Component: build
  • Affected Version: openjfx11
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2018-07-10
  • Updated: 2022-02-01
  • Resolved: 2018-07-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
openjfx11Fixed
Related Reports
Relates :  
Relates :  
Description
Steps to reproduce:

1. Download https://download.java.net/java/early_access/openjfx11/17/binaries/openjfx-11-ea+17_windows-x64_bin-sdk.zip

2. Download https://download.java.net/java/early_access/jdk11/21/GPL/openjdk-11-ea+21_windows-x64_bin.zip

3. Unzip the OpenJDK and OpenJFX bundles

4. Run jlink as follows:

    jdk-11/bin/jlink.exe --module-path javafx-jmods-11 --add-modules "java.se,javafx.controls" --output myjdk-11

It will produce the following exception:

Error: jdk.tools.jlink.plugin.PluginException: Duplicate resources: {bin\api-ms-win-crt-string-l1-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-crt-heap-l1-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-core-timezone-l1-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-crt-locale-l1-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-crt-runtime-l1-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-crt-conio-l1-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-core-processenvironment-l1-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-crt-stdio-l1-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-core-synch-l1-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-core-interlocked-l1-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-core-file-l2-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-core-namedpipe-l1-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-crt-time-l1-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-core-libraryloader-l1-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-core-debug-l1-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-core-heap-l1-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-core-console-l1-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-crt-private-l1-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-crt-environment-l1-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-crt-math-l1-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-core-errorhandling-l1-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-core-processthreads-l1-1-1.dll=[javafx.graphics, java.base], bin\ucrtbase.dll=[javafx.graphics, java.base], bin\api-ms-win-crt-convert-l1-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-core-sysinfo-l1-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-core-file-l1-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-core-localization-l1-2-0.dll=[javafx.graphics, java.base], bin\api-ms-win-crt-process-l1-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-core-profile-l1-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-crt-filesystem-l1-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-crt-multibyte-l1-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-core-datetime-l1-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-core-file-l1-2-0.dll=[javafx.graphics, java.base], bin\api-ms-win-crt-utility-l1-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-core-handle-l1-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-core-memory-l1-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-core-rtlsupport-l1-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-core-processthreads-l1-1-0.dll=[javafx.graphics, java.base], bin\api-ms-win-core-synch-l1-2-0.dll=[javafx.graphics, java.base], bin\api-ms-win-core-util-l1-1-0.dll=[javafx.graphics, java.base], bin\vcruntime140.dll=[javafx.graphics, java.base], bin\api-ms-win-core-string-l1-1-0.dll=[javafx.graphics, java.base], bin\msvcp140.dll=[javafx.graphics, java.base]}
Comments
I agree it is not trivial to come up with a clear algorithm on what to do in case duplicate resources are detected, so deferring is wise, and should probably be tackled in a follow-up issue.
24-07-2018

Changeset: 21b47529863d Author: kcr Date: 2018-07-21 06:14 -0700 URL: http://hg.openjdk.java.net/openjfx/jfx-dev/rt/rev/21b47529863d 8207015: jlink javafx.graphics on Windows fails: PluginException: Duplicate resources Reviewed-by: jvos, mbilla
23-07-2018

I commented on the PR at the link https://github.com/javafxports/openjdk-jfx/pull/136 While both the PR or the workaround (with --exclude-files) work, I am afraid there will be more similar issues like this in the future. When bundling other modules with core modules, there is always a risk of duplicated resources. The producer of the third party module can not rely on some libraries to be present in the core modules, as those libraries are not part of the specification. I actually have a related issue with a graphical application that is using opencv and that duplicates resources that are also in javafx.iio. So I wonder if the assemble logic in jlink should be improved in order to tackle these kinds of issues in a general way?
21-07-2018

I agree that this is an issue worth considering in a more general way. I had a conversation about this with Mandy when the bug was first filed, and she thought that an option to suppress the error was something to consider for an RFE in the JDK, but also pointed out that it would raise the issue of how to resolve duplicate resources. In a case like the Microsoft DLLs, which are intended to be identical and the "primary" ones are in java.base, it's easy to resolve with no ambiguity. It becomes harder when the duplicate resources are in two modules other than java.base ... which one do you take? what if the files have the same name, but not the identical contents? I think these are solvable problems, but they need to be considered.
21-07-2018

PR for review: https://github.com/javafxports/openjdk-jfx/pull/136 Evaluation: This bug only affects the jmod bundles. used by jlink, that we provide as part of the OpenJFX SDK. As such the simplest, and least intrusive fix is to exclude the Microsoft DLLs from the jmod bundles, but keep them in the standalone SDK and the maven modules. One implication of this change is that developers who use OpenJDK 10 to link an image with OpenJFX 11 jmods on Windows platforms will produce a bundle that might not run on some older Windows 7 machines without the most recent updates. I doubt this will be a problem in practice. Developers who want to create a custom image using jlink that includes OpenJFX 11 can and should use JDK 11 as the base. Note that the standalone SDK and the maven modules will continue to run with JDK 10 on older Windows 7 machines, since they will include the Microsoft DLLs that might be missing on such machines.
20-07-2018

Here is a preliminary PR on GitHub, mainly to make sure that it builds OK on all platforms (that is, doesn't break on Mac and Linux). https://github.com/javafxports/openjdk-jfx/pull/136
20-07-2018

This was caused by the recent compiler upgrade to VS 2017 that was done in JDK 11. Prior to this, JavaFX needed to ship the Microsoft redistributables from VS 2017 (and Windows 10 SDK) since the JDK did not. Now that they are shipped and included with java.base, we get a duplicate resource exception as shown above. The fix is likely to stop including them with openjfx modules, but we need to consider the long-term implications of this. WORKAROUND: Add the following option to jlink: --exclude-files "glob:/javafx.graphics/lib/api-ms*.dll,glob:/javafx.graphics/lib/ucrtbase.dll,glob:/javafx.graphics/lib/vcruntime140.dll,glob:/javafx.graphics/lib/msvcp140.dll"
10-07-2018