Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jlink deprecation warning for --compress '2' parameter on JDK21 #383

Closed
2 of 5 tasks
streamingdv opened this issue Dec 6, 2023 · 9 comments
Closed
2 of 5 tasks
Labels
enhancement New feature or request feedback Waiting for feedback fixed Issue fixed and release pending

Comments

@streamingdv
Copy link

I'm submitting a…

  • bug report
  • feature request
  • other

Short description of the issue/suggestion:

Deprecation warning is printed by jlink when used on a computer with JDK 21 installed

Steps to reproduce the issue/enhancement:

Use javapackger on a machine where JAVA_HOME is set to JDK 21

What is the expected behavior?

Ideally no deprecation warnings

What is the current behavior?

jlink produces following warning:

The 2 argument for --compress is deprecated and may be removed in a future release

Please tell us about your environment:

  • JavaPackager version: 1.7.5
  • OS version: Windows 11
  • JDK version: openjdk 21.0.1 2023-10-17 LTS
  • Build tool:
    • Maven
    • Gradle

Other information (e.g. related issues, suggestions how to fix, links for us to have context)

https://nipafx.dev/road-to-21-upgrade/#tools

@fvarrui
Copy link
Owner

fvarrui commented Dec 13, 2023

Hi @streamingdv!
Thanks for letting me know!
Should this argument be omitted when JDK>=21 or should it be replaced with another one?

@fvarrui fvarrui added the enhancement New feature or request label Dec 13, 2023
@streamingdv
Copy link
Author

@fvarrui according to the link I posted above following is mentioned

jlink's option --compress now accepts values zip0 to zip9 instead of the more abstract 0, 1, 2.

So I guess on java >= 21 switching to --compress zip2 should get rid of the warning and should provide the same functionality but I di not check if zip2 does really the same thing as the old 2 parameter.

@fvarrui
Copy link
Owner

fvarrui commented Dec 13, 2023

Oh! Sorry, I didn't notice the link 😅

@Xiphoseer
Copy link

Xiphoseer commented Jan 24, 2024

FYI: 0-9 in the context of ZIP is the zlib/deflate compression level (which is a choice between speed and size and has nothing to do with the previous 0/1/2), and based on https://github.com/openjdk/jdk/blob/6d2f6408e417b267be0345f63656f232cf247b6d/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ZipPlugin.java#L48 the equivalent to --compress=2 seems to be zip-6.

Edit: See also https://github.com/openjdk/jdk/blob/67f29b16ef963ff1710e306da811633aa4e182ac/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties#L85-L87

@trashgod
Copy link

For reference, given jlink version 21.0.2,

$ jlink --help
…
    --compress <compress>  Compression to use in compressing resources:
        Accepted values are:
        zip-[0-9], where zip-0 provides no compression,
        and zip-9 provides the best compression.
        Default is zip-6.
        Deprecated values to be removed in a future release:
        0:  No compression. Equivalent to zip-0.
        1:  Constant String Sharing
        2:  Equivalent to zip-6.
…

@fvarrui
Copy link
Owner

fvarrui commented Feb 25, 2024

Ok, as zip-6 seems to be the default value for --compress, now JP just omit --compress param if Java >= 21:

			// generates customized jre using modules
			CommandUtils.execute(
					jlink, 
					"--module-path", modulesDir, 
					additionalModulePathsToParams(additionalModulePaths),
					"--add-modules", modules, 
					"--output", destinationFolder, 
					"--no-header-files", 
					"--no-man-pages", 
					"--strip-debug", 
					(VersionUtils.getJavaMajorVersion() < 21 ? "--compress=2" : null)
				);

@fvarrui
Copy link
Owner

fvarrui commented Feb 25, 2024

Fixed!!!
JP snapshot version 1.7.6-20240225.211252-1 released to Maven Central.
Please, test it and give some feedback, so we can release this fix in JP 1.7.6.
Thanks!

@fvarrui fvarrui added the feedback Waiting for feedback label Feb 25, 2024
@fvarrui fvarrui added the fixed Issue fixed and release pending label Apr 23, 2024
@fvarrui
Copy link
Owner

fvarrui commented Apr 23, 2024

I tested It with different JDK versions and it seems to be working fine

@fvarrui
Copy link
Owner

fvarrui commented Jun 30, 2024

v1.7.6 released to Maven Central

@fvarrui fvarrui closed this as completed Jun 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feedback Waiting for feedback fixed Issue fixed and release pending
Projects
None yet
Development

No branches or pull requests

4 participants