In an effort to improve Java performance in cloud environments, an OpenJDK proposal is afoot to reduce the size of the JDK (Java Development Kit) by about 25%. The plan calls for enabling the jlink
tool to build custom runtime images without using the JDK’s JMOD files.
The JDK Enhancement Proposal (JEP), titled Linking Run-Time Images without JMODs, is motivated by the desire to reduce the installed size of the JDK on the file system in cloud environments, where container images that include an installed JDK are frequently copied over the network from container registries. Reducing the size of the JDK would improve the efficiency of these operations, the proposal states. The JEP notes that enabling the jlink
tool to create custom runtime images without using the JDK’s JMOD files must be enabled when the JDK is built and will not be enabled by default. Some JDK vendors may choose not to enable it.
The proposal explains that a complete, installed JDK has two main components: a run-time image, which serves as the executable Java runtime system, and a set of packaged modules, in the JMOD format, for each module in the runtime image. JMOD files are used by the jlink
tool when creating custom runtime images. The runtime image in a complete JDK itself was created from these JMOD files via jlink
. Hence, every class file, native library, configuration file, and other resource in the runtime image also is present in one of the JMOD files, which is arguably a “massive waste of space,” according to the proposal.
The JMOD files in a complete JDK account for about 25% of the JDK’s total size. If the jlink
tool could be enhanced to extract class files, configuration files, native libraries, and other resources from the runtime image itself, then the size of the installed JDK could be dramatically reduced by omitting the JMOD files. The plan would introduce a JDK build-time configuration option, --enable-linkable-runtime
that builds a JDK with a jlink
tool that can create runtime images without using the JDK’s JMOD files. The resulting JDK would be about 25% smaller than a JDK built with the default configuration and would contain the same modules.