jenkins icon indicating copy to clipboard operation
jenkins copied to clipboard

Simplify Util-methods for checking JVM version

Open Chrimle opened this issue 1 year ago • 8 comments

Given the fact that JVM versions were prefixed with '1.' until Java 9, there are 2 helper methods regarding the Java version being used; 'Java 8 or older' and 'Java 9 or newer'.

Since the methods are mutually exclusive and are essentially an inverse of one another, the issue was that both methods get the runtime Java version and then check if the version begins with '1.'. But because of the inverse property, only one method needs to do this check, and the other call the first and invert the result.

Chrimle avatar Jun 15 '23 20:06 Chrimle

Yay, your first pull request towards Jenkins core was created successfully! Thank you so much!

A contributor will provide feedback soon. Meanwhile, you can join the chats and community forums to connect with other Jenkins users, developers, and maintainers.

welcome[bot] avatar Jun 15 '23 20:06 welcome[bot]

Considering that Jenkins is built with java11 you could simply return true for isRunningWithPostJava8 and false for isRunningWithJava8OrBelow That said these methods seems to be obsolete somehow maybe they should be deprecated together with the JavaVersionRecommendationAdminMonitor for now. At a later point in time it might make sense to reactivate this when Jenkins wants to recommend using java 17 maybe.

mawinter69 avatar Jun 16 '23 19:06 mawinter69

That said these methods seems to be obsolete somehow maybe they should be deprecated

That'd make sense, although that'd be something for a different PR, to cleanup the Java 8 warning stuff.

Hey @Chrimle,

do you think you can apply the simplification recommended?

NotMyFault avatar Jul 01 '23 14:07 NotMyFault

Hi @NotMyFault & @mawinter69 !

Sure thing, I could to the suggested changes. Should I at the same time also mark these as deprecated?

Chrimle avatar Jul 01 '23 15:07 Chrimle

Is there a specific 'since' version that should be referenced instead of a date?

Description of Deprecation;

@deprecated because the current version is at least Java 11, this method is redundant.

Chrimle avatar Jul 01 '23 18:07 Chrimle

Is there a specific 'since' version that should be referenced instead of a date?

TODO; automatic tooling will fill in the tag version it has been released in.

NotMyFault avatar Jul 01 '23 19:07 NotMyFault

TODO; automatic tooling will fill in the tag version it has been released in.

Oh, very cool! Will update this. Thanks!

Chrimle avatar Jul 01 '23 19:07 Chrimle

Just FYI, you need to mark this PR as "Ready for review" over draft, to get reviews 👀

NotMyFault avatar Aug 06 '23 14:08 NotMyFault