JEP 223: New Version-String Scheme

Iris Clark iris.clark at oracle.com
Fri Aug 21 05:10:28 UTC 2015


Hi, Jorn.

Sorry for the delayed response.  

I've investigated the history around $PRE comparison.  It seems that the earliest drafts of this JEP contain the mixed numerical/lexicographical comparison algorithm which has the flaw that you (and others) have pointed out.   The best way to handle this without introducing the complete semver.org notion of dot-separated identifiers (again our goal is to subset semver.org as much as possible), is to follow semver.org's lead and declare precedence of numeric and non-numeric identifiers.  As you have suggested.

I'll be sending a "Verona spec:" message containing the precise modifications shortly.

Thanks,
iris

-----Original Message-----
From: Jörn Huxhorn [mailto:jhuxhorn at googlemail.com] 
Sent: Wednesday, July 15, 2015 11:41 AM
To: verona-dev at openjdk.java.net; Iris Clark
Subject: RE: JEP 223: New Version-String Scheme

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=13
> > 602386&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