< prev index next >

src/java.base/share/classes/java/lang/Runtime.java

Print this page
rev 15134 : [mq]: hack_version


1095          * <a href="#verNum">version number</a> followed by pre-release and
1096          * build information.
1097          *
1098          * @param  s
1099          *         A string to interpret as a version
1100          *
1101          * @throws  IllegalArgumentException
1102          *          If the given string cannot be interpreted as a valid
1103          *          version
1104          *
1105          * @throws  NullPointerException
1106          *          If the given string is {@code null}
1107          *
1108          * @throws  NumberFormatException
1109          *          If an element of the version number or the build number
1110          *          cannot be represented as an {@link Integer}
1111          *
1112          * @return  The Version of the given string
1113          */
1114         public static Version parse(String s) {







1115             return VersionBuilder.parse(s);
1116         }
1117 
1118         /**
1119          * Returns the <a href="#major">major</a> version number.
1120          *
1121          * @return  The major version number
1122          */
1123         public int major() {
1124             return version.get(0);
1125         }
1126 
1127         /**
1128          * Returns the <a href="#minor">minor</a> version number or zero if it
1129          * was not set.
1130          *
1131          * @return  The minor version number or zero if it was not set
1132          */
1133         public int minor() {
1134             return (version.size() > 1 ? version.get(1) : 0);




1095          * <a href="#verNum">version number</a> followed by pre-release and
1096          * build information.
1097          *
1098          * @param  s
1099          *         A string to interpret as a version
1100          *
1101          * @throws  IllegalArgumentException
1102          *          If the given string cannot be interpreted as a valid
1103          *          version
1104          *
1105          * @throws  NullPointerException
1106          *          If the given string is {@code null}
1107          *
1108          * @throws  NumberFormatException
1109          *          If an element of the version number or the build number
1110          *          cannot be represented as an {@link Integer}
1111          *
1112          * @return  The Version of the given string
1113          */
1114         public static Version parse(String s) {
1115             // Fast path to optimize Runtime.Version.parse(Integer.toString(8));
1116             if (s.indexOf('.') == -1
1117                     && s.indexOf('-') == -1
1118                     && s.indexOf('+') == -1) {
1119                 return new Version(List.of(Integer.parseInt(s)),
1120                         Optional.empty(), Optional.empty(), Optional.empty());
1121             }
1122             return VersionBuilder.parse(s);
1123         }
1124 
1125         /**
1126          * Returns the <a href="#major">major</a> version number.
1127          *
1128          * @return  The major version number
1129          */
1130         public int major() {
1131             return version.get(0);
1132         }
1133 
1134         /**
1135          * Returns the <a href="#minor">minor</a> version number or zero if it
1136          * was not set.
1137          *
1138          * @return  The minor version number or zero if it was not set
1139          */
1140         public int minor() {
1141             return (version.size() > 1 ? version.get(1) : 0);


< prev index next >