Comparable<Runtime.Version>public static class Runtime.Version extends Object implements Comparable<Runtime.Version>
A version number, $VNUM, is a non-empty sequence
of elements separated by period characters (U+002E). An element is
either zero, or a 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:
$MAJOR.$MINOR.$SECURITY
$MAJOR --- The major version
number, incremented for a major release that contains significant new
features as specified in a new edition of the Java SE Platform
Specification, e.g., JSR 337 for
Java SE 8. Features may be removed in a major release, given
advance notice at least one major release ahead of time, and
incompatible changes may be made when justified. The $MAJOR
version number of JDK 8 is 8; the $MAJOR version
number of JDK 9 is 9. When $MAJOR is incremented,
all subsequent elements are removed.
$MINOR --- The minor version
number, incremented for a minor update release that may contain
compatible bug fixes, revisions to standard APIs mandated by a
Maintenance Release
of the relevant Platform Specification, and implementation features
outside the scope of that Specification such as new JDK-specific APIs,
additional service providers, new garbage collectors, and ports to new
hardware architectures.
$SECURITY --- The security
level, incremented for a security update release that contains critical
fixes including those necessary to improve security. $SECURITY
is not reset when $MINOR is incremented. A
higher value of $SECURITY for a given $MAJOR value,
therefore, always indicates a more secure release, regardless of the
value of $MINOR.
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.
A version string, $VSTR, consists of a version
number $VNUM, as described above, optionally followed by
pre-release and build information, in the format
$VNUM(-$PRE)?(\+($BUILD)?(-$OPT)?)?
where:
$PRE, matching ([a-zA-Z0-9]+)
--- A pre-release identifier. Typically ea, for a
potentially unstable early-access release under active development,
or internal, for an internal developer build.
$BUILD, matching
(0|[1-9][0-9]*) --- The build number, incremented for each promoted
build. $BUILD is reset to 1 when any portion of
$VNUM is incremented.
$OPT, matching
([-a-zA-Z0-9\.]+) --- Additional build information, if desired. In
the case of an internal build this will often contain the date
and time of the build.
A version number 10-ea matches $VNUM = "10" and
$PRE = "ea". The version number 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:
$VNUM(-$PRE)?
| Modifier and Type | Method | Description |
|---|---|---|
Optional<Integer> |
build() |
Returns the build number.
|
int |
compareTo(Runtime.Version ob) |
Compares this version to another.
|
int |
compareToIgnoreOptional(Runtime.Version ob) |
Compares this version to another disregarding optional build
information.
|
boolean |
equals(Object ob) |
Determines whether this
Version is equal to another object. |
boolean |
equalsIgnoreOptional(Object ob) |
Determines whether this
Version is equal to another
disregarding optional build information. |
int |
hashCode() |
Returns the hash code of this version.
|
int |
major() |
Returns the major version number.
|
int |
minor() |
Returns the minor version number or zero if it
was not set.
|
Optional<String> |
optional() |
Returns optional additional identifying build
information.
|
static Runtime.Version |
parse(String s) |
Parses the given string as a valid
version string containing a
version number followed by pre-release and
build information.
|
Optional<String> |
pre() |
Returns the optional pre-release information.
|
int |
security() |
Returns the security version number or zero
if it was not set.
|
String |
toString() |
Returns a string representation of this version.
|
List<Integer> |
version() |
Returns an unmodifiable
List of the
integer numerals contained in the version
number. |
public static Runtime.Version parse(String s)
s - A string to interpret as a versionIllegalArgumentException - If the given string cannot be interpreted as a valid
versionNullPointerException - If the given string is nullNumberFormatException - If an element of the version number or the build number
cannot be represented as an Integerpublic int major()
public int minor()
public int security()
public List<Integer> version()
List of the
integer numerals contained in the version
number. The List always contains at least one
element corresponding to the major version
number.public Optional<String> pre()
public Optional<Integer> build()
public Optional<String> optional()
public int compareTo(Runtime.Version ob)
Each of the components in the version is compared in the follow order of precedence: version numbers, pre-release identifiers, build numbers, optional build information.
Comparison begins by examining the sequence of version numbers. 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.
A version with a pre-release identifier is always considered to be less than a version without one. Pre-release identifiers are compared numerically when they consist only of digits, and lexicographically otherwise. Numeric identifiers are considered to be less than non-numeric identifiers.
A version without a build number is always less than one with a build number; otherwise build numbers are compared numerically.
The optional build information is compared lexicographically. During this comparison, a version with optional build information is considered to be greater than a version without one.
A version is not comparable to any other type of object.
compareTo in interface Comparable<Runtime.Version>ob - The object to be comparedVersion is less than, equal to, or greater than the
given VersionNullPointerException - If the given object is nullpublic int compareToIgnoreOptional(Runtime.Version ob)
Two versions are compared by examining the version string as
described in compareTo(Version) with the exception that the
optional build information is always ignored.
A version is not comparable to any other type of object.
ob - The object to be comparedVersion is less than, equal to, or greater than the
given VersionNullPointerException - If the given object is nullpublic String toString()
public boolean equals(Object ob)
Version is equal to another object.
Two Versions are equal if and only if they represent the
same version string.
This method satisfies the general contract of the Object.equals method.
equals in class Objectob - The object to which this Version is to be comparedtrue if, and only if, the given object is a
Version that is identical to this VersionObject.hashCode(),
HashMappublic boolean equalsIgnoreOptional(Object ob)
Version is equal to another
disregarding optional build information.
Two Versions are equal if and only if they represent the
same version string disregarding the optional build information.
ob - The object to which this Version is to be comparedtrue if, and only if, the given object is a
Version that is identical to this Version
ignoring the optinal build informationpublic int hashCode()
This method satisfies the general contract of the Object.hashCode method.
hashCode in class ObjectObject.equals(java.lang.Object),
System.identityHashCode(java.lang.Object) Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2017, Oracle and/or its affiliates. 500 Oracle Parkway
Redwood Shores, CA 94065 USA. All rights reserved.
DRAFT 9-Debian+0-9b153-2