RFR: 8306678: Replace use of os.version with an internal Version record

Roger Riggs rriggs at openjdk.org
Fri Apr 21 20:44:41 UTC 2023


On Fri, 21 Apr 2023 20:21:33 GMT, Christian Stein <cstein 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 87:
> 
>> 85:         }
>> 86:         assertThrows(exception, () -> Version.parse(verName));
>> 87:     }
> 
> The explicit creation of argument instances can be avoided by using something like:
> 
> 
>     @ParameterizedTest
>     @ValueSource(strings = {
>             // dot without digits
>             "1.", "1.2.", "1.-abc", "1.2.-abc",
>             // empty
>             "",
>             // no an initial digit
>             "xaaa", "abc.xyz"
>     })
>     void checkIllegalParse(String verName) {
>         checkIllegalParse(verName, IllegalArgumentException.class);
>     }
> 
>     void checkIllegalParse(String verName, Class<? extends Throwable> exception) {
>         assertThrows(exception, () -> Version.parse(verName));
>     }

When I first wrote the test, I expected to be checking for different exceptions and messages on each case.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/13584#discussion_r1174148657


More information about the nio-dev mailing list