jmod and modular MR jars

Alan Bateman Alan.Bateman at oracle.com
Sat Oct 14 08:25:37 UTC 2017


On 13/10/2017 21:54, Ryan Schmitt wrote:
> :
>
> In the general case, I do have to worry about native libraries. I'm 
> trying to figure out what it would mean to add end-to-end support for 
> fully modularized Jigsaw applications to my company's build 
> infrastructure, and JMOD packaging *might* be a good default strategy 
> for tackling that problem. However, I'm not sure how `jmod` interacts 
> with MR JAR files. There are three possibilities here:
>
> (1) I'm invoking `jmod` incorrectly. I'm using (jmod create 
> --class-path <MR jar file containing a module> <jmod file>`)
> (2) There is a bug in `jmod` that prevents it from identifying and 
> using META-INF/versions/9/module-info.class
> (3) `jmod`, like `javac`, intentionally disregards classes in the 
> META-INF/versions area
>
> I don't see anything in JEP 238 or JEP 261 to suggest that (3) would 
> be the case, nor do I see any documented `jmod` flags that would be 
> relevant to MR jars (similar to the `--multi-release` argument to 
> `jdeps`).
The JMOD format does not have the equivalent of META-INF/versions. The 
`jmod` tool does not know anything about MR JARs.

When you create a JMOD file with the `jmod` tool then you must specify 
the location of the classes, launchers, native libraries, license files, 
etc. to include. For the classes then you'll typically specify the 
top-level directory (where module-info.class exists). The `jmod` tool 
can read the classes from a modular JAR too but it has no support for 
reading the classes from a modular MR JARs. In particular, it will 
always reject modular MR JARs where the module-info.class is in a 
versioned section rather than the top-level directory.

Yes, it's technically possible of course, at least for the case where 
you choose the version at packaging time so that the resulting JMOD only 
contains the classes/resources to target a specific JDK version. 
Deferring the version selection to link time would mean the JMOD format 
would need to support the equivalent of META-INF/versions.

As regards `javac` (which you mention in #3) then it does support MR 
JARs (I assume that is a typo in your mail and you mention another tool, 
maybe `javap`).

-Alan


More information about the jdk9-dev mailing list