Is it better for JDK to distribute jmod files independently of JDK itself?

Glavo zjx001202 at gmail.com
Tue Feb 8 14:17:17 UTC 2022


Since Java 9, JDK has been distributed with jmod files bundled with all
modules. I am confused by this release strategy.

One important problem is that this expands the size of JDK's compressed
package by 60% (~ 70MB), and the decompressed size expands by 30%.
This takes up a lot of extra hard disk space, and more importantly, it
causes a lot of bandwidth waste.
Many times we only want a JDK and don't need jlink (especially CI
environment), but unfortunately I haven't seen any openjdk distribution
provide such things.

Conversely, when I use jlink, it also annoys me. I want to use a dedicated
Linux machine to compile the program and use jlink to generate the runtime
for each platform.
On this machine, I only need a JDK of Linux AMD64 and jmod files of JDK of
various platforms,
but I have never seen any provider provide JDK's jmod files separately, so
I have to download one complete JDK after another,
even if I can't use them at all except jmod files. When the number of
target platforms increases, the waste caused by this increases sharply.

These wastes seem to be less important for a single JDK, but in some
scenarios (CI, container, virtual machine, etc), a large number of jdks may
need to be downloaded and stored,
and these wastes cannot be ignored.

Now I'm confused about the current distribution method. Would it be a
better choice to distribute JDK and jmod separately?

In addition, I think there are other better options for the out-of-the-box
availability of jlink.
I noticed that a copy of everything in jmod already exists in the JDK
folder.
In fact, jmod of JDK core module only needs to store a file list (List of
paths of all native libraries, executable files and legal files),
original content backup of some modifiable content (e.g. conf files), and
the name of module.
We can re extract the complete jmod file from JDK through these meta
information, the size of these meta information is completely negligible.
I'm spending some free time trying to implement such a tool, and I don't
think it's difficult.

I think if jlink can recognize this kind of meta information, JDK only
needs to bundle these trivial meta information contents,
and the complete jmod file is distributed separately from JDK, which may be
the best choice.

These are my immature ideas. I hope I can get your advice. Thank you.


More information about the jigsaw-dev mailing list