Runtime.Version (Java SE 9 & JDK 9 ) (original) (raw)

A representation of a version string for an implementation of the Java SE Platform. A version string consists of a version number optionally followed by pre-release and build information.

Version numbers

A version number, $VNUM, is a non-empty sequence of elements separated by period characters (U+002E). An element is either zero, or an unsigned integer numeral without leading zeros. The final element in a version number must not be zero. The format is:

[1-9][0-9]*((\.0)*\.[1-9][0-9]*)*

The sequence may be of arbitrary length but the first three elements are assigned specific meanings, as follows:

<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>M</mi><mi>A</mi><mi>J</mi><mi>O</mi><mi>R</mi><mi mathvariant="normal">.</mi></mrow><annotation encoding="application/x-tex">MAJOR.</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">M</span><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.09618em;">J</span><span class="mord mathnormal" style="margin-right:0.00773em;">OR</span><span class="mord">.</span></span></span></span>MINOR.$SECURITY

The fourth and later elements of a version number are free for use by downstream consumers of this code base. Such a consumer may,e.g., use the fourth element to identify patch releases which contain a small number of critical non-security fixes in addition to the security fixes in the corresponding security release.

The version number does not include trailing zero elements;i.e., $SECURITY is omitted if it has the value zero, and $MINOR is omitted if both $MINOR and $SECURITY have the value zero.

The sequence of numerals in a version number is compared to another such sequence in numerical, pointwise fashion; e.g., 9.9.1 is less than 9.10.3. If one sequence is shorter than another then the missing elements of the shorter sequence are considered to be less than the corresponding elements of the longer sequence; e.g., 9.1.2 is less than 9.1.2.1.

Version strings

A version string, $VSTR, consists of a version number $VNUM, as described above, optionally followed by pre-release and build information, in one of the following formats:

<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>V</mi><mi>N</mi><mi>U</mi><mi>M</mi><mo stretchy="false">(</mo><mo>−</mo></mrow><annotation encoding="application/x-tex">VNUM(-</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mord mathnormal" style="margin-right:0.10903em;">N</span><span class="mord mathnormal" style="margin-right:0.10903em;">U</span><span class="mord mathnormal" style="margin-right:0.10903em;">M</span><span class="mopen">(</span><span class="mord">−</span></span></span></span>PRE)?\+$BUILD(-$OPT)?
<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>V</mi><mi>N</mi><mi>U</mi><mi>M</mi><mo>−</mo></mrow><annotation encoding="application/x-tex">VNUM-</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7667em;vertical-align:-0.0833em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mord mathnormal" style="margin-right:0.10903em;">N</span><span class="mord mathnormal" style="margin-right:0.10903em;">U</span><span class="mord mathnormal" style="margin-right:0.10903em;">M</span><span class="mord">−</span></span></span></span>PRE(-$OPT)?
<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>V</mi><mi>N</mi><mi>U</mi><mi>M</mi><mo stretchy="false">(</mo><mo>+</mo><mo>−</mo></mrow><annotation encoding="application/x-tex">VNUM(+-</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mord mathnormal" style="margin-right:0.10903em;">N</span><span class="mord mathnormal" style="margin-right:0.10903em;">U</span><span class="mord mathnormal" style="margin-right:0.10903em;">M</span><span class="mopen">(</span><span class="mord">+</span><span class="mord">−</span></span></span></span>OPT)?

where:

A version string 10-ea matches $VNUM = "10" and$PRE = "ea". The version string 10+-ea matches$VNUM = "10" and $OPT = "ea".

When comparing two version strings, the value of $OPT, if present, may or may not be significant depending on the chosen comparison method. The comparison methods compareTo() and compareToIgnoreOptional() should be used consistently with the corresponding methods equals() and equalsIgnoreOptional().

A short version string, $SVSTR, often useful in less formal contexts, is a version number optionally followed by a pre-release identifier:

<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>V</mi><mi>N</mi><mi>U</mi><mi>M</mi><mo stretchy="false">(</mo><mo>−</mo></mrow><annotation encoding="application/x-tex">VNUM(-</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mord mathnormal" style="margin-right:0.10903em;">N</span><span class="mord mathnormal" style="margin-right:0.10903em;">U</span><span class="mord mathnormal" style="margin-right:0.10903em;">M</span><span class="mopen">(</span><span class="mord">−</span></span></span></span>PRE)?

This is a value-based class; use of identity-sensitive operations (including reference equality (==), identity hash code, or synchronization) on instances ofVersion may have unpredictable results and should be avoided.