RFR: 8306678: Replace use of os.version with an internal Version record
Christian Stein
cstein at openjdk.org
Fri Apr 21 20:18:46 UTC 2023
On Fri, 21 Apr 2023 16:44:13 GMT, Roger Riggs <rriggs at openjdk.org> wrote:
> Create an internal Version record to hold and compare versions of the form (major, minor, micro).
> Add `OperatingSystem.version()` to return the version of the running OS.
> Replace uses of os.version in java.base.
> Subsequent PRs will apply to uses in other modules including, jdk.jlink, jdk.jpackage, and java.desktop.
test/jdk/jdk/internal/util/VersionTest.java line 64:
> 62: Version actual = Version.parse(verName);
> 63: assertEquals(actual, expected, "Parsed version mismatch");
> 64: }
Another way to declare arguments is to use `CsvSource` like:
@ParameterizedTest
@CsvSource(textBlock =
"""
1, 0, 0, 1
1, 2, 0, 1.2
1, 2, 0, 1.2.0
1, 2, 3, 1.2.3
# Ignore extra trailing characters
1, 0, 0, 1-abc
1, 2, 0, 1.2-abc
1, 2, 3, 1.2.3.4
1, 2, 3, 1.2.3-abc
""")
void checkParse(int major, int minor, int micro, Version actual) {
Version expected = new Version(major, minor, micro);
assertEquals(expected, actual, "Parsed version mismatch");
}
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13584#discussion_r1174131270
More information about the core-libs-dev
mailing list