An exploratory prototype for reducing the size of the JDK: Fallback Jmod
Glavo
zjx001202 at gmail.com
Thu Feb 17 01:25:14 UTC 2022
I talked about Jmod on the Jigsaw mailing list the other day. [1]
The current distribution method of Jmod files has caused a lot of redundant
information in the JDK,
which makes the size of the JDK unnecessarily enlarged, which brings
unnecessary troubles to CI, containers, and virtual machines.
At the same time, the lack of a separately distributed Jmod file also
brings more trouble to the use of Jlink.
During this time, I spent two nights implementing a prototype.
I used it based on SapMachine JDK, it works without breaking any JDK
functionality (in theory),
and it worked to my satisfaction.
It reduces the size of `sapmachine-jdk-17.0.2.tar.gz` from 184MB to 115MB,
and the decompressed size is reduced from 316MB to 242M.
It greatly reduces the size of the Jmod file by reusing the files that
already exist in the JDK while ensuring that the files are not lossless.
By calculating and recording the file hash value, it will not cause the
content of Jmod to be irreversibly modified due to file differences caused
by Jlink plugins.
All files that may not be recovered, such as files with conflicting
contents in the runtime image and Jmod, and configuration files, etc., are
kept in Jmod to ensure that the reduction process is really lossless.
At the same time, I also implemented a Jlink plugin, which can be used by
Jlink transparently without pre-recovery.
I put this prototype on GitHub, I hope it will be an exploration of the
future of OpenJDK.
And I hope that similar feature will hopefully be integrated into the JDK
at some point in the future,
rely on this to reduce the size of the JDK distribution.
I want to get your opinions, thank you so much.
Here is its GitHub repository:
https://github.com/Glavo/fallback-jmod/
[1]:
https://mail.openjdk.java.net/pipermail/jigsaw-dev/2022-February/014780.html
More information about the jigsaw-dev
mailing list