Java Cup
Inside Java

News and views from members of the Java team at Oracle

JDK 26: Jlink Compression Plugin Now Handles -c Option Correctly - Quality Outreach Heads-up

The OpenJDK Quality Group promotes the testing of FOSS projects with OpenJDK early-access builds as a way to improve the overall quality of the release. This heads-up is part of a Quality Outreach update sent to the projects involved. To learn more about the program and how to join, please check the Quality Outreach wiki page.

Align Behavior and Documentation About Jlink Compression

The jlink tool guide states that you can set compression level using the --compress option or its short form -c.

jlink --module-path $JAVA_HOME/jmods/ \
    --add-modules java.base \
    --compress=zip-1 \
    --output runtime

Furthermore, while not documented, a command like the one below produces a runtime image compressed with the deprecated compression level 2.

jlink --module-path $JAVA_HOME/jmods/ \
    --add-modules java.base \
    -c \
    --output runtime

Yet, prior to JDK 26, utilizing jlink with -c followed by an argument would result in an error. This behavior has been corrected in JDK 26 and running jlink with either --compress or -c produces the same result:

jlink --module-path $JAVA_HOME/jmods/ \
    --add-modules java.base \
    -c zip-1 \
    --output runtime

Call to Action

By aligning the behavior of -c and --compress for jlink, both options now require an argument. If you use jlink -c without specifying an argument for compression level, it is recommended to either select a level or omit the option altogether. In the latter case, the resulting runtime image will be compressed using the default compression level (zip-6).

This fix has been incorporated into the 26-ea mainline build available here. For more details on this change, check JDK-8321139.

~