Runtime Version Parse Feature And Build
Break a version string apart with Runtime.Version.parse: feature, interim, update and patch come back as ints while pre, build and optional arrive as Optionals.
Code
public class VersionInspector {
static void describe(String tag, Runtime.Version v) {
System.out.println(tag + " raw: " + v);
System.out.println(" version(): " + v.version());
System.out.println(" feature: " + v.feature());
System.out.println(" interim: " + v.interim());
System.out.println(" update: " + v.update());
System.out.println(" patch: " + v.patch());
System.out.println(" pre: " + v.pre());
System.out.println(" build: " + v.build());
System.out.println(" optional: " + v.optional());
}
public static void main(String[] args) {
// 语法 $VNUM(+$BUILD(-$OPT)?):21.0.5 + build 9 + 可选信息 LTS
describe("lts", Runtime.Version.parse("21.0.5+9-LTS"));
System.out.println();
// 无 build 的预发布串:pre 有值,build 是空 Optional
describe("ea", Runtime.Version.parse("20-ea"));
System.out.println();
Runtime.Version running = Runtime.version();
System.out.println("running jvm feature: " + running.feature());
}
}What the code does
Runtime Version Parse Feature And Build is built around the class VersionInspector and the functions describe and main.
Watch out for
- The project needs no additions before running it.
Using it
Signature: static void describe(String tag, Runtime.Version v)
The run emits 9 labeled sections — version():, feature:, interim:, update:, patch:, pre:, build:, optional:, running jvm feature: — one per step.
Execute the file and main walks through describe, in that order.
The key statements, annotated
describe("lts", Runtime.Version.parse("21.0.5+9-LTS"));
describe("ea", Runtime.Version.parse("20-ea"));
Runtime.Version running = Runtime.version();
Interactive Tools for This Topic
Git Conventional Commit BuilderBuild and validate Conventional Commits v1.0.0 messages with type, scope, breaking markers, 72-char subject counter, body, footers, and git CLI command.Glob Pattern TesterCompile glob patterns with *, **, ?, character classes, and braces into regex and test them against a list of candidate file paths.SemVer Range CheckerCheck whether a semantic version satisfies an npm-style range such as caret, tilde, comparison sets, wildcards, or hyphen ranges.SemVer SorterParse and sort Semantic Version 2.0.0 strings with prerelease and build metadata, respecting prerelease-below-release precedence.
FAQ
- What does Runtime Version Parse Feature And Build print when run?
- Execute the whole file; each printed line is prefixed with a label like `version():`, `feature:`, `interim:`.
Report a problem with this exampleOpens a pre-filled issue on GitHub.