src/java.base/windows/native/libjava/java_props_md.c
changeset 52571 c02aa8873ff2
parent 52478 b915bd68d907
child 52836 98792298b309
equal deleted inserted replaced
52570:a2413ed39eff 52571:c02aa8873ff2
     1 /*
     1 /*
     2  * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   357 GetJavaProperties(JNIEnv* env)
   357 GetJavaProperties(JNIEnv* env)
   358 {
   358 {
   359     static java_props_t sprops = {0};
   359     static java_props_t sprops = {0};
   360     int majorVersion;
   360     int majorVersion;
   361     int minorVersion;
   361     int minorVersion;
       
   362     int buildNumber = 0;
   362 
   363 
   363     if (sprops.line_separator) {
   364     if (sprops.line_separator) {
   364         return &sprops;
   365         return &sprops;
   365     }
   366     }
   366 
   367 
   396             OSVERSIONINFOEX ver;
   397             OSVERSIONINFOEX ver;
   397             ver.dwOSVersionInfoSize = sizeof(ver);
   398             ver.dwOSVersionInfoSize = sizeof(ver);
   398             GetVersionEx((OSVERSIONINFO *) &ver);
   399             GetVersionEx((OSVERSIONINFO *) &ver);
   399             majorVersion = ver.dwMajorVersion;
   400             majorVersion = ver.dwMajorVersion;
   400             minorVersion = ver.dwMinorVersion;
   401             minorVersion = ver.dwMinorVersion;
       
   402             /* distinguish Windows Server 2016 and 2019 by build number */
       
   403             buildNumber = ver.dwBuildNumber;
   401             is_workstation = (ver.wProductType == VER_NT_WORKSTATION);
   404             is_workstation = (ver.wProductType == VER_NT_WORKSTATION);
   402             platformId = ver.dwPlatformId;
   405             platformId = ver.dwPlatformId;
   403             sprops.patch_level = _strdup(ver.szCSDVersion);
   406             sprops.patch_level = _strdup(ver.szCSDVersion);
   404         }
   407         }
   405 
   408 
   446                 free(version_info);
   449                 free(version_info);
   447                 break;
   450                 break;
   448             }
   451             }
   449             majorVersion = HIWORD(file_info->dwProductVersionMS);
   452             majorVersion = HIWORD(file_info->dwProductVersionMS);
   450             minorVersion = LOWORD(file_info->dwProductVersionMS);
   453             minorVersion = LOWORD(file_info->dwProductVersionMS);
       
   454             buildNumber  = HIWORD(file_info->dwProductVersionLS);
   451             free(version_info);
   455             free(version_info);
   452         } while (0);
   456         } while (0);
   453 
   457 
   454         /*
   458         /*
   455          * From msdn page on OSVERSIONINFOEX, current as of this
   459          * From msdn page on OSVERSIONINFOEX, current as of this
   476          * Windows 8                    6               2  (VER_NT_WORKSTATION)
   480          * Windows 8                    6               2  (VER_NT_WORKSTATION)
   477          * Windows Server 2012          6               2  (!VER_NT_WORKSTATION)
   481          * Windows Server 2012          6               2  (!VER_NT_WORKSTATION)
   478          * Windows Server 2012 R2       6               3  (!VER_NT_WORKSTATION)
   482          * Windows Server 2012 R2       6               3  (!VER_NT_WORKSTATION)
   479          * Windows 10                   10              0  (VER_NT_WORKSTATION)
   483          * Windows 10                   10              0  (VER_NT_WORKSTATION)
   480          * Windows Server 2016          10              0  (!VER_NT_WORKSTATION)
   484          * Windows Server 2016          10              0  (!VER_NT_WORKSTATION)
       
   485          * Windows Server 2019          10              0  (!VER_NT_WORKSTATION)
       
   486          *       where (buildNumber > 17762)
   481          *
   487          *
   482          * This mapping will presumably be augmented as new Windows
   488          * This mapping will presumably be augmented as new Windows
   483          * versions are released.
   489          * versions are released.
   484          */
   490          */
   485         switch (platformId) {
   491         switch (platformId) {
   549                     case  0: sprops.os_name = "Windows 10";           break;
   555                     case  0: sprops.os_name = "Windows 10";           break;
   550                     default: sprops.os_name = "Windows NT (unknown)";
   556                     default: sprops.os_name = "Windows NT (unknown)";
   551                     }
   557                     }
   552                 } else {
   558                 } else {
   553                     switch (minorVersion) {
   559                     switch (minorVersion) {
   554                     case  0: sprops.os_name = "Windows Server 2016";           break;
   560                     case  0:
       
   561                         /* Windows server 2019 GA 10/2018 build number is 17763 */
       
   562                         if (buildNumber > 17762) {
       
   563                             sprops.os_name = "Windows Server 2019";
       
   564                         } else {
       
   565                             sprops.os_name = "Windows Server 2016";
       
   566                         }
       
   567                         break;
   555                     default: sprops.os_name = "Windows NT (unknown)";
   568                     default: sprops.os_name = "Windows NT (unknown)";
   556                     }
   569                     }
   557                 }
   570                 }
   558             } else {
   571             } else {
   559                 sprops.os_name = "Windows NT (unknown)";
   572                 sprops.os_name = "Windows NT (unknown)";