JEP 223: New Version-String Scheme

Jörn Huxhorn jhuxhorn at googlemail.com
Wed Jul 15 18:40:40 UTC 2015


Hi Iris,

Thanks for your answers. Very much appreciated.


On 15. Juli 2015 at 20:18:39, Iris Clark (iris.clark at oracle.com) wrote:
> JEP 223 is currently targeted for JDK 9 (see the "Status" and "Release"
> fields).

I saw that. I just wasn’t 100% sure about the values the Status field can have and what exactly “Targeted" means. Thanks for clearing that up.


> > The "Pre-release identifiers are compared numerically when they consist only
> > of digits, and lexicographically otherwise.” part is a bit concerning and
> > doesn’t really adhere to the principle of least surprise.
>  
> > I currently handle it this way in Comparable:
> > http://pastebin.com/7xaizUKm …but it makes me feel kind of dirty.
>  
> > Wouldn’t it make more sense to just rule that pre should be compared
> > lexicographically? I think
> > https://bugs.openjdk.java.net/browse/JDK-8061493?focusedCommentId=13602386&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13602386  
> > has a very valid point.
>  
> Hmmm... I'm going to have to think about this. The comparison was supposed to
> attempt to align us with semver.org handling of pre-release identifiers.
> There have also been some considered adjustments to that area of the spec
> since it was originally written to handle specific concerns. I'm going to
> need to dig out my notes.

With the current compareTo implementation according to the spec, sorting of versions is behaving quite erratic:

Collections.sort([9.0.0-4, 9.0.0-2A, 9.0.0-12]) => [9.0.0-12, 9.0.0-2A, 9.0.0-4]
Collections.sort([9.0.0-4, 9.0.0-12, 9.0.0-2A]) => [9.0.0-4, 9.0.0-12, 9.0.0-2A]
Collections.sort([9.0.0-12, 9.0.0-2A, 9.0.0-4]) => [9.0.0-12, 9.0.0-2A, 9.0.0-4]
Collections.sort([9.0.0-12, 9.0.0-4, 9.0.0-2A]) => [9.0.0-2A, 9.0.0-4, 9.0.0-12]

This just can’t be correct.

I just checked http://semver.org/

Paragraph 11 contains the following definition which would fix this problem:
"Numeric identifiers always have lower precedence than non-numeric identifiers."

I think this should also be added to JEP 223 accordingly. I’ll definitely go ahead and implement it that way instead.

Cheers,
Jörn.


More information about the verona-dev mailing list