Closed hohwille closed 5 months ago
Suggestion: Follow TDD with Red/Green pattern and first extend test-version-compare by adding the example from this story. Then this test should fail. After that try to implement the story and rerun the test until it is green.
Vising https://adoptium.net/ confirms that this is a bug and
21.0.1_12
is newer than21_35
. Indeed an edge-case from the version compare function but with Java a very relevant one. The problem is that semantics like.
vs._
are actually undefined. However, if both versions have an underscore (_
) it seems kind of natural to first compare the prefix part before the underscore and only if equal then compare the suffix part so:21.0.1
<=>21
-->21.0.1
>21
12
<=>35
-->12
<35
.A remaining question would be the comparison of
21.0.1.12
with21_35
and IMHO there can not be a clear answer as it may depend on the project/product creating these versions.I guess for Java the suffix starting with the
_
is some kind of build number.