Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

Comparable version string is not comparable #47

Description

@steve-in-ont

The output of the comparableJavaVersionNumber() function is used to compare JRE versions, but the strings produced are then compared using the "-ge" operator which does a numeric comparison, NOT a lexical comparison. To illustrate with an example, here's the output version strings I get for the JDK versions installed on my Mac:

Version 1.6.0_65 results in "6065"
Version 1.7.0_45 results in "7045"
Version 1.8.0_101 results in "80101"
Version 9 results in "9"

When comparing the output strings all versions less than version 9 are considered greater than version 9. Also, because a 3 digit patch number results in a 5-digit version string, a 1.7 level JRE (for example) with patch number greater than 100 would have a larger version string than a 1.8 level JRE with a patch number less than 100.

Perhaps normalizing the length of the version string to 6 or 7 digits would fix the problem. This would result in strings like:

"606500"
"704500"
"801010"
"900000"

These are directly comparable using the "-ge" operator.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions