Skip to content

Commit

Permalink
8274840: Update OS detection code to recognize Windows 11
Browse files Browse the repository at this point in the history
Reviewed-by: phh
Backport-of: 97ea9dd2f24f9f1fb9b9345a4202a825ee28e014
  • Loading branch information
rgithubli authored and jerboaa committed Aug 30, 2022
1 parent 266918d commit bd946fa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 5 additions & 1 deletion hotspot/src/os/windows/vm/os_windows.cpp
Expand Up @@ -1818,7 +1818,11 @@ void os::win32::print_windows_version(outputStream* st) {

case 10000:
if (is_workstation) {
st->print("10");
if (build_number >= 22000) {
st->print("11");
} else {
st->print("10");
}
} else {
// distinguish Windows Server by build number
// - 2016 GA 10/2016 build: 14393
Expand Down
11 changes: 10 additions & 1 deletion jdk/src/windows/native/java/lang/java_props_md.c
Expand Up @@ -473,6 +473,8 @@ GetJavaProperties(JNIEnv* env)
* Windows Server 2012 6 2 (!VER_NT_WORKSTATION)
* Windows Server 2012 R2 6 3 (!VER_NT_WORKSTATION)
* Windows 10 10 0 (VER_NT_WORKSTATION)
* Windows 11 10 0 (VER_NT_WORKSTATION)
* where (buildNumber >= 22000)
* Windows Server 2016 10 0 (!VER_NT_WORKSTATION)
* Windows Server 2019 10 0 (!VER_NT_WORKSTATION)
* where (buildNumber > 17762)
Expand Down Expand Up @@ -546,7 +548,14 @@ GetJavaProperties(JNIEnv* env)
} else if (majorVersion == 10) {
if (is_workstation) {
switch (minorVersion) {
case 0: sprops.os_name = "Windows 10"; break;
case 0:
/* Windows 11 21H2 (original release) build number is 22000 */
if (buildNumber >= 22000) {
sprops.os_name = "Windows 11";
} else {
sprops.os_name = "Windows 10";
}
break;
default: sprops.os_name = "Windows NT (unknown)";
}
} else {
Expand Down

1 comment on commit bd946fa

@openjdk-notifier
Copy link

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.