JDK-8156499 : Update jlink to support creating images with modules that are packaged as multi-release JARs
  • Type: Sub-task
  • Component: tools
  • Sub-Component: jlink
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2016-05-08
  • Updated: 2016-11-04
  • Resolved: 2016-11-01
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.
JDK 9
9 b143Fixed
Related Reports
Relates :  
Description
The jlink tool will require updates to work with modular JARs that are multi-release JARs.

Consider the following with jdk9/dev today:

$ jar tf m1.jar
META-INF/
META-INF/MANIFEST.MF
module-info.class
META-INF/versions/
META-INF/versions/9/
META-INF/versions/9/module-info.class
META-INF/versions/9/p/
META-INF/versions/9/p/Main.class
META-INF/versions/9/p/Type.class
p/
p/Main.class

$ jlink --output myimage --addmods m1 --modulepath m1.jar:$JAVA_HOME/jmods
Error: module-info.class not found for META-INF module

The main issue is that jlink attempts to create the runtime image with all resources in the modular JAR, it should only read the module classes/resources that are appropriate for the target JDK version.

Another part is that jlink doesn't know the target major version and doesn't have any ability to configure the ModuleFinder so that the module declaration for that release is used. 


Comments
Is there a way to decompose myimage to actually see what is linked in? I'm not familiar with this, but it is interesting to me. In fact, maybe I should assign this issue to me. Ah, I see. Using jimage list against myimage/lib/modules shows me what's in the image. And I see what this issue is about: Module: m1 META-INF/MANIFEST.MF META-INF/versions/9/p/Main.class META-INF/versions/9/p/Type.class module-info.class p/Main.class
02-08-2016

There are several pieces to be done on this. The main thing is for jlink to include the classes/resources for the right version into the jimage - currently it links in all classes/resources but those in META-INF/versions/9 will be ignored at run-time. We also need to make sure that we can support targeting different versions in the future.
02-08-2016

Is this still a problem? It seems to work now. $ jar tf m1.jar META-INF/ META-INF/MANIFEST.MF module-info.class META-INF/versions/9/module-info.class p/ p/Main.class META-INF/versions/9/ META-INF/versions/9/p/ META-INF/versions/9/p/Main.class META-INF/versions/9/p/Type.class $ jlink --output myimage --addmods m1 --modulepath m1.jar:$JAVA_HOME/jmods $
02-08-2016