Skip to content
Permalink
Browse files
8273229: Update OS detection code to recognize Windows Server 2022
Backport-of: c2e015c3c1a2274112bb8e6671a85bc7fb624fde
  • Loading branch information
TheRealMDoerr committed Oct 8, 2021
1 parent 63367e3 commit eeab2f199907d3ad0dc9e08170241cc0986ac82b
Showing 2 changed files with 14 additions and 5 deletions.
@@ -1708,9 +1708,13 @@ void os::win32::print_windows_version(outputStream* st) {
if (is_workstation) {
st->print("10");
} else {
// distinguish Windows Server 2016 and 2019 by build number
// Windows server 2019 GA 10/2018 build number is 17763
if (build_number > 17762) {
// distinguish Windows Server by build number
// - 2016 GA 10/2016 build: 14393
// - 2019 GA 11/2018 build: 17763
// - 2022 GA 08/2021 build: 20348
if (build_number > 20347) {
st->print("Server 2022");
} else if (build_number > 17762) {
st->print("Server 2019");
} else {
st->print("Server 2016");
@@ -393,7 +393,7 @@ GetJavaProperties(JNIEnv* env)
GetVersionEx((OSVERSIONINFO *) &ver);
majorVersion = ver.dwMajorVersion;
minorVersion = ver.dwMinorVersion;
/* distinguish Windows Server 2016 and 2019 by build number */
/* distinguish Windows Server 2016+ by build number */
buildNumber = ver.dwBuildNumber;
is_workstation = (ver.wProductType == VER_NT_WORKSTATION);
platformId = ver.dwPlatformId;
@@ -478,6 +478,8 @@ GetJavaProperties(JNIEnv* env)
* Windows Server 2016 10 0 (!VER_NT_WORKSTATION)
* Windows Server 2019 10 0 (!VER_NT_WORKSTATION)
* where (buildNumber > 17762)
* Windows Server 2022 10 0 (!VER_NT_WORKSTATION)
* where (buildNumber > 20347)
*
* This mapping will presumably be augmented as new Windows
* versions are released.
@@ -553,7 +555,10 @@ GetJavaProperties(JNIEnv* env)
switch (minorVersion) {
case 0:
/* Windows server 2019 GA 10/2018 build number is 17763 */
if (buildNumber > 17762) {
/* Windows server 2022 build number is 20348 */
if (buildNumber > 20347) {
sprops.os_name = "Windows Server 2022";
} else if (buildNumber > 17676) {
sprops.os_name = "Windows Server 2019";
} else {
sprops.os_name = "Windows Server 2016";

1 comment on commit eeab2f1

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on eeab2f1 Oct 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.