JDK-8160954 : (spec) Runtime.Version regex and $PRE/$OPT issues
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 9
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2016-07-07
  • Updated: 2017-05-19
  • Resolved: 2017-04-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 10 JDK 9
10Fixed 9 b167Fixed
Related Reports
Relates :  
Relates :  
Description
1) Runtime.Version spec says regarding $VNUM format:
"The format is: ^[1-9][0-9]*(((\.0)*\.[1-9][0-9]*)*)*$"
There is "$" in the end of $VNUM. "$" is end of line template.
However, the following code will throw IllegalArgumentException:

Version.parse("1.1.1" + System.lineSeparator());

Seems this is the spec problem and the template should be updated to the same but without "$" in the end.

2) According to the current spec the template for the version string is
$VNUM(-$PRE)?(\+($BUILD)?(-$OPT)?)?
There is no words regarding the case when $PRE and $OPT is used without $BUILD or when "+" is used without $BUILD and $OPT.
However, the following code will throw IllegalArgumentException:

- Version.parse("1.1.1-ea+--abc");
- Version.parse("1.1.1-ea+");

Seems this is the spec problem and the spec need to be supplemented with exception cases.