author | prr |
Fri, 10 May 2019 16:22:35 -0700 | |
changeset 54877 | dde07ac16610 |
parent 54865 | 99337f94b04d |
child 57826 | bf4c808a4488 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
52571
c02aa8873ff2
8211106: [windows] Update OS detection code to recognize Windows Server 2019
mbaesken
parents:
52478
diff
changeset
|
2 |
* Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
15291 | 26 |
/* Access APIs for Windows Vista and above */ |
27 |
#ifndef _WIN32_WINNT |
|
28 |
#define _WIN32_WINNT 0x0601 |
|
29 |
#endif |
|
30 |
||
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
31 |
#include "jni.h" |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
32 |
#include "jni_util.h" |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
33 |
|
2 | 34 |
#include <windows.h> |
35 |
#include <shlobj.h> |
|
36 |
#include <objidl.h> |
|
37 |
#include <locale.h> |
|
38 |
#include <sys/types.h> |
|
39 |
#include <sys/timeb.h> |
|
40 |
#include <tchar.h> |
|
41 |
||
11906
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
42 |
#include <stdlib.h> |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
43 |
#include <Wincon.h> |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
44 |
|
2 | 45 |
#include "locale_str.h" |
46 |
#include "java_props.h" |
|
47 |
||
48 |
#ifndef VER_PLATFORM_WIN32_WINDOWS |
|
49 |
#define VER_PLATFORM_WIN32_WINDOWS 1 |
|
50 |
#endif |
|
51 |
||
1626
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
52 |
#ifndef PROCESSOR_ARCHITECTURE_AMD64 |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
53 |
#define PROCESSOR_ARCHITECTURE_AMD64 9 |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
54 |
#endif |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
55 |
|
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
56 |
typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO); |
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
57 |
static boolean SetupI18nProps(LCID lcid, char** language, char** script, char** country, |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
58 |
char** variant, char** encoding); |
1626
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
59 |
|
7017 | 60 |
#define PROPSIZE 9 // eight-letter + null terminator |
61 |
#define SNAMESIZE 86 // max number of chars for LOCALE_SNAME is 85 |
|
62 |
||
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
63 |
static char * |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
64 |
getEncodingInternal(LCID lcid) |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
65 |
{ |
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
66 |
int codepage; |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
67 |
char * ret = malloc(16); |
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
68 |
if (ret == NULL) { |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
69 |
return NULL; |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
70 |
} |
2 | 71 |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
72 |
if (GetLocaleInfo(lcid, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
73 |
LOCALE_IDEFAULTANSICODEPAGE, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
74 |
ret+2, 14) == 0) { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
75 |
codepage = 1252; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
76 |
} else { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
77 |
codepage = atoi(ret+2); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
78 |
} |
2 | 79 |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
80 |
switch (codepage) { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
81 |
case 0: |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
82 |
strcpy(ret, "UTF-8"); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
83 |
break; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
84 |
case 874: /* 9:Thai */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
85 |
case 932: /* 10:Japanese */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
86 |
case 949: /* 12:Korean Extended Wansung */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
87 |
case 950: /* 13:Chinese (Taiwan, Hongkong, Macau) */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
88 |
case 1361: /* 15:Korean Johab */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
89 |
ret[0] = 'M'; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
90 |
ret[1] = 'S'; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
91 |
break; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
92 |
case 936: |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
93 |
strcpy(ret, "GBK"); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
94 |
break; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
95 |
case 54936: |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
96 |
strcpy(ret, "GB18030"); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
97 |
break; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
98 |
default: |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
99 |
ret[0] = 'C'; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
100 |
ret[1] = 'p'; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
101 |
break; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
102 |
} |
2 | 103 |
|
5167
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
3288
diff
changeset
|
104 |
//Traditional Chinese Windows should use MS950_HKSCS_XP as the |
2 | 105 |
//default encoding, if HKSCS patch has been installed. |
106 |
// "old" MS950 0xfa41 -> u+e001 |
|
107 |
// "new" MS950 0xfa41 -> u+92db |
|
108 |
if (strcmp(ret, "MS950") == 0) { |
|
109 |
TCHAR mbChar[2] = {(char)0xfa, (char)0x41}; |
|
110 |
WCHAR unicodeChar; |
|
111 |
MultiByteToWideChar(CP_ACP, 0, mbChar, 2, &unicodeChar, 1); |
|
112 |
if (unicodeChar == 0x92db) { |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
113 |
strcpy(ret, "MS950_HKSCS_XP"); |
2 | 114 |
} |
115 |
} else { |
|
116 |
//SimpChinese Windows should use GB18030 as the default |
|
117 |
//encoding, if gb18030 patch has been installed (on windows |
|
118 |
//2000/XP, (1)Codepage 54936 will be available |
|
119 |
//(2)simsun18030.ttc will exist under system fonts dir ) |
|
120 |
if (strcmp(ret, "GBK") == 0 && IsValidCodePage(54936)) { |
|
121 |
char systemPath[MAX_PATH + 1]; |
|
122 |
char* gb18030Font = "\\FONTS\\SimSun18030.ttc"; |
|
123 |
FILE *f = NULL; |
|
124 |
if (GetWindowsDirectory(systemPath, MAX_PATH + 1) != 0 && |
|
125 |
strlen(systemPath) + strlen(gb18030Font) < MAX_PATH + 1) { |
|
126 |
strcat(systemPath, "\\FONTS\\SimSun18030.ttc"); |
|
127 |
if ((f = fopen(systemPath, "r")) != NULL) { |
|
128 |
fclose(f); |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
129 |
strcpy(ret, "GB18030"); |
2 | 130 |
} |
131 |
} |
|
132 |
} |
|
133 |
} |
|
134 |
||
135 |
return ret; |
|
136 |
} |
|
137 |
||
11906
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
138 |
static char* getConsoleEncoding() |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
139 |
{ |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
140 |
char* buf = malloc(16); |
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
141 |
int cp; |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
142 |
if (buf == NULL) { |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
143 |
return NULL; |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
144 |
} |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
145 |
cp = GetConsoleCP(); |
11906
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
146 |
if (cp >= 874 && cp <= 950) |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
147 |
sprintf(buf, "ms%d", cp); |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
148 |
else |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
149 |
sprintf(buf, "cp%d", cp); |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
150 |
return buf; |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
151 |
} |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
152 |
|
2 | 153 |
// Exported entries for AWT |
154 |
DllExport const char * |
|
155 |
getEncodingFromLangID(LANGID langID) |
|
156 |
{ |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
157 |
return getEncodingInternal(MAKELCID(langID, SORT_DEFAULT)); |
2 | 158 |
} |
159 |
||
7017 | 160 |
// Returns BCP47 Language Tag |
2 | 161 |
DllExport const char * |
162 |
getJavaIDFromLangID(LANGID langID) |
|
163 |
{ |
|
7017 | 164 |
char * elems[5]; // lang, script, ctry, variant, encoding |
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
165 |
char * ret; |
7017 | 166 |
int index; |
167 |
||
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
168 |
ret = malloc(SNAMESIZE); |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
169 |
if (ret == NULL) { |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
170 |
return NULL; |
2 | 171 |
} |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
172 |
|
51943
5e9c922eafbc
8211149: fix potential memleak in getJavaIDFromLangID after failing SetupI18nProps call [windows]
mbaesken
parents:
49213
diff
changeset
|
173 |
for (index = 0; index < 5; index++) { |
5e9c922eafbc
8211149: fix potential memleak in getJavaIDFromLangID after failing SetupI18nProps call [windows]
mbaesken
parents:
49213
diff
changeset
|
174 |
elems[index] = NULL; |
5e9c922eafbc
8211149: fix potential memleak in getJavaIDFromLangID after failing SetupI18nProps call [windows]
mbaesken
parents:
49213
diff
changeset
|
175 |
} |
5e9c922eafbc
8211149: fix potential memleak in getJavaIDFromLangID after failing SetupI18nProps call [windows]
mbaesken
parents:
49213
diff
changeset
|
176 |
|
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
177 |
if (SetupI18nProps(MAKELCID(langID, SORT_DEFAULT), |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
178 |
&(elems[0]), &(elems[1]), &(elems[2]), &(elems[3]), &(elems[4]))) { |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
179 |
|
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
180 |
// there always is the "language" tag |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
181 |
strcpy(ret, elems[0]); |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
182 |
|
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
183 |
// append other elements, if any |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
184 |
for (index = 1; index < 4; index++) { |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
185 |
if ((elems[index])[0] != '\0') { |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
186 |
strcat(ret, "-"); |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
187 |
strcat(ret, elems[index]); |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
188 |
} |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
189 |
} |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
190 |
} else { |
29116
9918719cfcc0
8055204: Memory leak in jdk/src/windows/native/java/lang/java_props_md.c
msheppar
parents:
25859
diff
changeset
|
191 |
free(ret); |
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
192 |
ret = NULL; |
7017 | 193 |
} |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
194 |
|
51943
5e9c922eafbc
8211149: fix potential memleak in getJavaIDFromLangID after failing SetupI18nProps call [windows]
mbaesken
parents:
49213
diff
changeset
|
195 |
for (index = 0; index < 5; index++) { |
5e9c922eafbc
8211149: fix potential memleak in getJavaIDFromLangID after failing SetupI18nProps call [windows]
mbaesken
parents:
49213
diff
changeset
|
196 |
if (elems[index] != NULL) { |
5e9c922eafbc
8211149: fix potential memleak in getJavaIDFromLangID after failing SetupI18nProps call [windows]
mbaesken
parents:
49213
diff
changeset
|
197 |
free(elems[index]); |
5e9c922eafbc
8211149: fix potential memleak in getJavaIDFromLangID after failing SetupI18nProps call [windows]
mbaesken
parents:
49213
diff
changeset
|
198 |
} |
5e9c922eafbc
8211149: fix potential memleak in getJavaIDFromLangID after failing SetupI18nProps call [windows]
mbaesken
parents:
49213
diff
changeset
|
199 |
} |
5e9c922eafbc
8211149: fix potential memleak in getJavaIDFromLangID after failing SetupI18nProps call [windows]
mbaesken
parents:
49213
diff
changeset
|
200 |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
201 |
return ret; |
2 | 202 |
} |
203 |
||
204 |
/* |
|
205 |
* Code to figure out the user's home directory using shell32.dll |
|
206 |
*/ |
|
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
207 |
WCHAR* |
2 | 208 |
getHomeFromShell32() |
209 |
{ |
|
15291 | 210 |
/* |
211 |
* Note that we don't free the memory allocated |
|
212 |
* by getHomeFromShell32. |
|
213 |
*/ |
|
214 |
static WCHAR *u_path = NULL; |
|
215 |
if (u_path == NULL) { |
|
216 |
HRESULT hr; |
|
2 | 217 |
|
15291 | 218 |
/* |
219 |
* SHELL32 DLL is delay load DLL and we can use the trick with |
|
220 |
* __try/__except block. |
|
221 |
*/ |
|
222 |
__try { |
|
223 |
/* |
|
224 |
* For Windows Vista and later (or patched MS OS) we need to use |
|
225 |
* [SHGetKnownFolderPath] call to avoid MAX_PATH length limitation. |
|
226 |
* Shell32.dll (version 6.0.6000 or later) |
|
227 |
*/ |
|
228 |
hr = SHGetKnownFolderPath(&FOLDERID_Profile, KF_FLAG_DONT_VERIFY, NULL, &u_path); |
|
229 |
} __except(EXCEPTION_EXECUTE_HANDLER) { |
|
230 |
/* Exception: no [SHGetKnownFolderPath] entry */ |
|
231 |
hr = E_FAIL; |
|
232 |
} |
|
2 | 233 |
|
15291 | 234 |
if (FAILED(hr)) { |
235 |
WCHAR path[MAX_PATH+1]; |
|
236 |
||
237 |
/* fallback solution for WinXP and Windows 2000 */ |
|
238 |
hr = SHGetFolderPathW(NULL, CSIDL_FLAG_DONT_VERIFY | CSIDL_PROFILE, NULL, SHGFP_TYPE_CURRENT, path); |
|
239 |
if (FAILED(hr)) { |
|
240 |
/* we can't find the shell folder. */ |
|
241 |
u_path = NULL; |
|
242 |
} else { |
|
243 |
/* Just to be sure about the path length until Windows Vista approach. |
|
244 |
* [S_FALSE] could not be returned due to [CSIDL_FLAG_DONT_VERIFY] flag and UNICODE version. |
|
245 |
*/ |
|
246 |
path[MAX_PATH] = 0; |
|
247 |
u_path = _wcsdup(path); |
|
248 |
} |
|
249 |
} |
|
250 |
} |
|
251 |
return u_path; |
|
2 | 252 |
} |
253 |
||
254 |
static boolean |
|
255 |
haveMMX(void) |
|
256 |
{ |
|
9027
540bd52f1881
7030249: Eliminate use of LoadLibrary and other clean-ups
alanb
parents:
7668
diff
changeset
|
257 |
return IsProcessorFeaturePresent(PF_MMX_INSTRUCTIONS_AVAILABLE); |
2 | 258 |
} |
259 |
||
260 |
static const char * |
|
261 |
cpu_isalist(void) |
|
262 |
{ |
|
263 |
SYSTEM_INFO info; |
|
264 |
GetSystemInfo(&info); |
|
265 |
switch (info.wProcessorArchitecture) { |
|
266 |
#ifdef PROCESSOR_ARCHITECTURE_IA64 |
|
267 |
case PROCESSOR_ARCHITECTURE_IA64: return "ia64"; |
|
268 |
#endif |
|
269 |
#ifdef PROCESSOR_ARCHITECTURE_AMD64 |
|
270 |
case PROCESSOR_ARCHITECTURE_AMD64: return "amd64"; |
|
271 |
#endif |
|
272 |
case PROCESSOR_ARCHITECTURE_INTEL: |
|
273 |
switch (info.wProcessorLevel) { |
|
274 |
case 6: return haveMMX() |
|
275 |
? "pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86" |
|
276 |
: "pentium_pro pentium i486 i386 i86"; |
|
277 |
case 5: return haveMMX() |
|
278 |
? "pentium+mmx pentium i486 i386 i86" |
|
279 |
: "pentium i486 i386 i86"; |
|
280 |
case 4: return "i486 i386 i86"; |
|
281 |
case 3: return "i386 i86"; |
|
282 |
} |
|
283 |
} |
|
284 |
return NULL; |
|
285 |
} |
|
286 |
||
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
287 |
static boolean |
7017 | 288 |
SetupI18nProps(LCID lcid, char** language, char** script, char** country, |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
289 |
char** variant, char** encoding) { |
7017 | 290 |
/* script */ |
291 |
char tmp[SNAMESIZE]; |
|
292 |
*script = malloc(PROPSIZE); |
|
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
293 |
if (*script == NULL) { |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
294 |
return FALSE; |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
295 |
} |
7017 | 296 |
if (GetLocaleInfo(lcid, |
297 |
LOCALE_SNAME, tmp, SNAMESIZE) == 0 || |
|
298 |
sscanf(tmp, "%*[a-z\\-]%1[A-Z]%[a-z]", *script, &((*script)[1])) == 0 || |
|
299 |
strlen(*script) != 4) { |
|
300 |
(*script)[0] = '\0'; |
|
301 |
} |
|
302 |
||
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
303 |
/* country */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
304 |
*country = malloc(PROPSIZE); |
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
305 |
if (*country == NULL) { |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
306 |
return FALSE; |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
307 |
} |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
308 |
if (GetLocaleInfo(lcid, |
7017 | 309 |
LOCALE_SISO3166CTRYNAME, *country, PROPSIZE) == 0 && |
310 |
GetLocaleInfo(lcid, |
|
311 |
LOCALE_SISO3166CTRYNAME2, *country, PROPSIZE) == 0) { |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
312 |
(*country)[0] = '\0'; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
313 |
} |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
314 |
|
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
315 |
/* language */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
316 |
*language = malloc(PROPSIZE); |
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
317 |
if (*language == NULL) { |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
318 |
return FALSE; |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
319 |
} |
7017 | 320 |
if (GetLocaleInfo(lcid, |
321 |
LOCALE_SISO639LANGNAME, *language, PROPSIZE) == 0 && |
|
322 |
GetLocaleInfo(lcid, |
|
323 |
LOCALE_SISO639LANGNAME2, *language, PROPSIZE) == 0) { |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
324 |
/* defaults to en_US */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
325 |
strcpy(*language, "en"); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
326 |
strcpy(*country, "US"); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
327 |
} |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
328 |
|
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
329 |
/* variant */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
330 |
*variant = malloc(PROPSIZE); |
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
331 |
if (*variant == NULL) { |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
332 |
return FALSE; |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
333 |
} |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
334 |
(*variant)[0] = '\0'; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
335 |
|
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
336 |
/* handling for Norwegian */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
337 |
if (strcmp(*language, "nb") == 0) { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
338 |
strcpy(*language, "no"); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
339 |
strcpy(*country , "NO"); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
340 |
} else if (strcmp(*language, "nn") == 0) { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
341 |
strcpy(*language, "no"); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
342 |
strcpy(*country , "NO"); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
343 |
strcpy(*variant, "NY"); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
344 |
} |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
345 |
|
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
346 |
/* encoding */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
347 |
*encoding = getEncodingInternal(lcid); |
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
348 |
if (*encoding == NULL) { |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
349 |
return FALSE; |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
350 |
} |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
351 |
return TRUE; |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
352 |
} |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
353 |
|
30784 | 354 |
// GetVersionEx is deprecated; disable the warning until a replacement is found |
355 |
#pragma warning(disable : 4996) |
|
2 | 356 |
java_props_t * |
357 |
GetJavaProperties(JNIEnv* env) |
|
358 |
{ |
|
359 |
static java_props_t sprops = {0}; |
|
31246
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
360 |
int majorVersion; |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
361 |
int minorVersion; |
52571
c02aa8873ff2
8211106: [windows] Update OS detection code to recognize Windows Server 2019
mbaesken
parents:
52478
diff
changeset
|
362 |
int buildNumber = 0; |
5167
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
3288
diff
changeset
|
363 |
|
15291 | 364 |
if (sprops.line_separator) { |
2 | 365 |
return &sprops; |
366 |
} |
|
367 |
||
368 |
/* tmp dir */ |
|
369 |
{ |
|
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
370 |
WCHAR tmpdir[MAX_PATH + 1]; |
2 | 371 |
/* we might want to check that this succeed */ |
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
372 |
GetTempPathW(MAX_PATH + 1, tmpdir); |
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
373 |
sprops.tmp_dir = _wcsdup(tmpdir); |
2 | 374 |
} |
375 |
||
376 |
/* OS properties */ |
|
377 |
{ |
|
378 |
char buf[100]; |
|
31246
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
379 |
boolean is_workstation; |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
380 |
boolean is_64bit; |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
381 |
DWORD platformId; |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
382 |
{ |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
383 |
OSVERSIONINFOEX ver; |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
384 |
ver.dwOSVersionInfoSize = sizeof(ver); |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
385 |
GetVersionEx((OSVERSIONINFO *) &ver); |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
386 |
majorVersion = ver.dwMajorVersion; |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
387 |
minorVersion = ver.dwMinorVersion; |
52571
c02aa8873ff2
8211106: [windows] Update OS detection code to recognize Windows Server 2019
mbaesken
parents:
52478
diff
changeset
|
388 |
/* distinguish Windows Server 2016 and 2019 by build number */ |
c02aa8873ff2
8211106: [windows] Update OS detection code to recognize Windows Server 2019
mbaesken
parents:
52478
diff
changeset
|
389 |
buildNumber = ver.dwBuildNumber; |
31246
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
390 |
is_workstation = (ver.wProductType == VER_NT_WORKSTATION); |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
391 |
platformId = ver.dwPlatformId; |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
392 |
sprops.patch_level = _strdup(ver.szCSDVersion); |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
393 |
} |
1626
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
394 |
|
31246
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
395 |
{ |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
396 |
SYSTEM_INFO si; |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
397 |
ZeroMemory(&si, sizeof(SYSTEM_INFO)); |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
398 |
GetNativeSystemInfo(&si); |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
399 |
|
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
400 |
is_64bit = (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64); |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
401 |
} |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
402 |
do { |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
403 |
// Read the major and minor version number from kernel32.dll |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
404 |
VS_FIXEDFILEINFO *file_info; |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
405 |
WCHAR kernel32_path[MAX_PATH]; |
31249
8bfa589f4c85
8129535: java_props_md.c should compile on VS 2010
rriggs
parents:
31246
diff
changeset
|
406 |
DWORD version_size; |
8bfa589f4c85
8129535: java_props_md.c should compile on VS 2010
rriggs
parents:
31246
diff
changeset
|
407 |
LPTSTR version_info; |
31246
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
408 |
UINT len, ret; |
2 | 409 |
|
31246
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
410 |
// Get the full path to \Windows\System32\kernel32.dll and use that for |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
411 |
// determining what version of Windows we're running on. |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
412 |
len = MAX_PATH - (UINT)strlen("\\kernel32.dll") - 1; |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
413 |
ret = GetSystemDirectoryW(kernel32_path, len); |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
414 |
if (ret == 0 || ret > len) { |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
415 |
break; |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
416 |
} |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
417 |
wcsncat(kernel32_path, L"\\kernel32.dll", MAX_PATH - ret); |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
418 |
|
31249
8bfa589f4c85
8129535: java_props_md.c should compile on VS 2010
rriggs
parents:
31246
diff
changeset
|
419 |
version_size = GetFileVersionInfoSizeW(kernel32_path, NULL); |
31246
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
420 |
if (version_size == 0) { |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
421 |
break; |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
422 |
} |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
423 |
|
31249
8bfa589f4c85
8129535: java_props_md.c should compile on VS 2010
rriggs
parents:
31246
diff
changeset
|
424 |
version_info = (LPTSTR)malloc(version_size); |
31246
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
425 |
if (version_info == NULL) { |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
426 |
break; |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
427 |
} |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
428 |
|
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
429 |
if (!GetFileVersionInfoW(kernel32_path, 0, version_size, version_info)) { |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
430 |
free(version_info); |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
431 |
break; |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
432 |
} |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
433 |
|
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
434 |
if (!VerQueryValueW(version_info, L"\\", (LPVOID*)&file_info, &len)) { |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
435 |
free(version_info); |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
436 |
break; |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
437 |
} |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
438 |
majorVersion = HIWORD(file_info->dwProductVersionMS); |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
439 |
minorVersion = LOWORD(file_info->dwProductVersionMS); |
52571
c02aa8873ff2
8211106: [windows] Update OS detection code to recognize Windows Server 2019
mbaesken
parents:
52478
diff
changeset
|
440 |
buildNumber = HIWORD(file_info->dwProductVersionLS); |
31246
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
441 |
free(version_info); |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
442 |
} while (0); |
1626
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
443 |
|
2 | 444 |
/* |
445 |
* From msdn page on OSVERSIONINFOEX, current as of this |
|
49
b25b3ff21b7c
6642034: System.getProperty("os.name") returns Windows Vista on Windows Server 2008 (longhorn)
martin
parents:
2
diff
changeset
|
446 |
* writing, decoding of dwMajorVersion and dwMinorVersion. |
2 | 447 |
* |
448 |
* Operating system dwMajorVersion dwMinorVersion |
|
449 |
* ================== ============== ============== |
|
450 |
* |
|
451 |
* Windows 95 4 0 |
|
452 |
* Windows 98 4 10 |
|
453 |
* Windows ME 4 90 |
|
454 |
* Windows 3.51 3 51 |
|
455 |
* Windows NT 4.0 4 0 |
|
456 |
* Windows 2000 5 0 |
|
1626
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
457 |
* Windows XP 32 bit 5 1 |
2 | 458 |
* Windows Server 2003 family 5 2 |
1626
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
459 |
* Windows XP 64 bit 5 2 |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
460 |
* where ((&ver.wServicePackMinor) + 2) = 1 |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
461 |
* and si.wProcessorArchitecture = 9 |
3212 | 462 |
* Windows Vista family 6 0 (VER_NT_WORKSTATION) |
463 |
* Windows Server 2008 6 0 (!VER_NT_WORKSTATION) |
|
464 |
* Windows 7 6 1 (VER_NT_WORKSTATION) |
|
465 |
* Windows Server 2008 R2 6 1 (!VER_NT_WORKSTATION) |
|
12843
f785258dea60
7170169: (props) System.getProperty("os.name") should return "Windows 8" when run on Windows 8
khazra
parents:
11906
diff
changeset
|
466 |
* Windows 8 6 2 (VER_NT_WORKSTATION) |
12873
e7c4a8144e66
7173645: (props) System.getProperty("os.name") should return "Windows Server 2012" for Windows Server 2012
khazra
parents:
12843
diff
changeset
|
467 |
* Windows Server 2012 6 2 (!VER_NT_WORKSTATION) |
36420
1709f0cad63f
8150490: Update OS detection code to recognize Windows Server 2016
ctornqvi
parents:
31249
diff
changeset
|
468 |
* Windows Server 2012 R2 6 3 (!VER_NT_WORKSTATION) |
31246
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
469 |
* Windows 10 10 0 (VER_NT_WORKSTATION) |
36420
1709f0cad63f
8150490: Update OS detection code to recognize Windows Server 2016
ctornqvi
parents:
31249
diff
changeset
|
470 |
* Windows Server 2016 10 0 (!VER_NT_WORKSTATION) |
52571
c02aa8873ff2
8211106: [windows] Update OS detection code to recognize Windows Server 2019
mbaesken
parents:
52478
diff
changeset
|
471 |
* Windows Server 2019 10 0 (!VER_NT_WORKSTATION) |
c02aa8873ff2
8211106: [windows] Update OS detection code to recognize Windows Server 2019
mbaesken
parents:
52478
diff
changeset
|
472 |
* where (buildNumber > 17762) |
2 | 473 |
* |
474 |
* This mapping will presumably be augmented as new Windows |
|
475 |
* versions are released. |
|
476 |
*/ |
|
31246
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
477 |
switch (platformId) { |
2 | 478 |
case VER_PLATFORM_WIN32_WINDOWS: |
31246
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
479 |
if (majorVersion == 4) { |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
480 |
switch (minorVersion) { |
2 | 481 |
case 0: sprops.os_name = "Windows 95"; break; |
482 |
case 10: sprops.os_name = "Windows 98"; break; |
|
483 |
case 90: sprops.os_name = "Windows Me"; break; |
|
484 |
default: sprops.os_name = "Windows 9X (unknown)"; break; |
|
485 |
} |
|
486 |
} else { |
|
487 |
sprops.os_name = "Windows 9X (unknown)"; |
|
488 |
} |
|
489 |
break; |
|
490 |
case VER_PLATFORM_WIN32_NT: |
|
31246
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
491 |
if (majorVersion <= 4) { |
2 | 492 |
sprops.os_name = "Windows NT"; |
31246
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
493 |
} else if (majorVersion == 5) { |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
494 |
switch (minorVersion) { |
2 | 495 |
case 0: sprops.os_name = "Windows 2000"; break; |
496 |
case 1: sprops.os_name = "Windows XP"; break; |
|
1626
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
497 |
case 2: |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
498 |
/* |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
499 |
* From MSDN OSVERSIONINFOEX and SYSTEM_INFO documentation: |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
500 |
* |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
501 |
* "Because the version numbers for Windows Server 2003 |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
502 |
* and Windows XP 6u4 bit are identical, you must also test |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
503 |
* whether the wProductType member is VER_NT_WORKSTATION. |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
504 |
* and si.wProcessorArchitecture is |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
505 |
* PROCESSOR_ARCHITECTURE_AMD64 (which is 9) |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
506 |
* If it is, the operating system is Windows XP 64 bit; |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
507 |
* otherwise, it is Windows Server 2003." |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
508 |
*/ |
31246
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
509 |
if (is_workstation && is_64bit) { |
1626
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
510 |
sprops.os_name = "Windows XP"; /* 64 bit */ |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
511 |
} else { |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
512 |
sprops.os_name = "Windows 2003"; |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
513 |
} |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
514 |
break; |
2 | 515 |
default: sprops.os_name = "Windows NT (unknown)"; break; |
516 |
} |
|
31246
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
517 |
} else if (majorVersion == 6) { |
49
b25b3ff21b7c
6642034: System.getProperty("os.name") returns Windows Vista on Windows Server 2008 (longhorn)
martin
parents:
2
diff
changeset
|
518 |
/* |
3212 | 519 |
* See table in MSDN OSVERSIONINFOEX documentation. |
49
b25b3ff21b7c
6642034: System.getProperty("os.name") returns Windows Vista on Windows Server 2008 (longhorn)
martin
parents:
2
diff
changeset
|
520 |
*/ |
31246
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
521 |
if (is_workstation) { |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
522 |
switch (minorVersion) { |
2424
3663fccf2fc3
6819886: System.getProperty("os.name") reports Vista on Windows 7
alanb
parents:
1626
diff
changeset
|
523 |
case 0: sprops.os_name = "Windows Vista"; break; |
3663fccf2fc3
6819886: System.getProperty("os.name") reports Vista on Windows 7
alanb
parents:
1626
diff
changeset
|
524 |
case 1: sprops.os_name = "Windows 7"; break; |
12843
f785258dea60
7170169: (props) System.getProperty("os.name") should return "Windows 8" when run on Windows 8
khazra
parents:
11906
diff
changeset
|
525 |
case 2: sprops.os_name = "Windows 8"; break; |
19190
50a4d01485a1
8020191: System.getProperty("os.name") returns "Windows NT (unknown)" on Windows 8.1
uta
parents:
15291
diff
changeset
|
526 |
case 3: sprops.os_name = "Windows 8.1"; break; |
2424
3663fccf2fc3
6819886: System.getProperty("os.name") reports Vista on Windows 7
alanb
parents:
1626
diff
changeset
|
527 |
default: sprops.os_name = "Windows NT (unknown)"; |
3663fccf2fc3
6819886: System.getProperty("os.name") reports Vista on Windows 7
alanb
parents:
1626
diff
changeset
|
528 |
} |
3663fccf2fc3
6819886: System.getProperty("os.name") reports Vista on Windows 7
alanb
parents:
1626
diff
changeset
|
529 |
} else { |
31246
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
530 |
switch (minorVersion) { |
3212 | 531 |
case 0: sprops.os_name = "Windows Server 2008"; break; |
532 |
case 1: sprops.os_name = "Windows Server 2008 R2"; break; |
|
12873
e7c4a8144e66
7173645: (props) System.getProperty("os.name") should return "Windows Server 2012" for Windows Server 2012
khazra
parents:
12843
diff
changeset
|
533 |
case 2: sprops.os_name = "Windows Server 2012"; break; |
19190
50a4d01485a1
8020191: System.getProperty("os.name") returns "Windows NT (unknown)" on Windows 8.1
uta
parents:
15291
diff
changeset
|
534 |
case 3: sprops.os_name = "Windows Server 2012 R2"; break; |
3212 | 535 |
default: sprops.os_name = "Windows NT (unknown)"; |
536 |
} |
|
2424
3663fccf2fc3
6819886: System.getProperty("os.name") reports Vista on Windows 7
alanb
parents:
1626
diff
changeset
|
537 |
} |
31246
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
538 |
} else if (majorVersion == 10) { |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
539 |
if (is_workstation) { |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
540 |
switch (minorVersion) { |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
541 |
case 0: sprops.os_name = "Windows 10"; break; |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
542 |
default: sprops.os_name = "Windows NT (unknown)"; |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
543 |
} |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
544 |
} else { |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
545 |
switch (minorVersion) { |
52571
c02aa8873ff2
8211106: [windows] Update OS detection code to recognize Windows Server 2019
mbaesken
parents:
52478
diff
changeset
|
546 |
case 0: |
c02aa8873ff2
8211106: [windows] Update OS detection code to recognize Windows Server 2019
mbaesken
parents:
52478
diff
changeset
|
547 |
/* Windows server 2019 GA 10/2018 build number is 17763 */ |
c02aa8873ff2
8211106: [windows] Update OS detection code to recognize Windows Server 2019
mbaesken
parents:
52478
diff
changeset
|
548 |
if (buildNumber > 17762) { |
c02aa8873ff2
8211106: [windows] Update OS detection code to recognize Windows Server 2019
mbaesken
parents:
52478
diff
changeset
|
549 |
sprops.os_name = "Windows Server 2019"; |
c02aa8873ff2
8211106: [windows] Update OS detection code to recognize Windows Server 2019
mbaesken
parents:
52478
diff
changeset
|
550 |
} else { |
c02aa8873ff2
8211106: [windows] Update OS detection code to recognize Windows Server 2019
mbaesken
parents:
52478
diff
changeset
|
551 |
sprops.os_name = "Windows Server 2016"; |
c02aa8873ff2
8211106: [windows] Update OS detection code to recognize Windows Server 2019
mbaesken
parents:
52478
diff
changeset
|
552 |
} |
c02aa8873ff2
8211106: [windows] Update OS detection code to recognize Windows Server 2019
mbaesken
parents:
52478
diff
changeset
|
553 |
break; |
31246
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
554 |
default: sprops.os_name = "Windows NT (unknown)"; |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
555 |
} |
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
556 |
} |
2 | 557 |
} else { |
558 |
sprops.os_name = "Windows NT (unknown)"; |
|
559 |
} |
|
560 |
break; |
|
561 |
default: |
|
562 |
sprops.os_name = "Windows (unknown)"; |
|
563 |
break; |
|
564 |
} |
|
31246
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
565 |
sprintf(buf, "%d.%d", majorVersion, minorVersion); |
6850
56966b0a6a0d
6989466: Miscellaneous compiler warnings in java/lang, java/util, java/io, sun/misc native code
alanb
parents:
6489
diff
changeset
|
566 |
sprops.os_version = _strdup(buf); |
46870 | 567 |
#if _M_AMD64 |
2 | 568 |
sprops.os_arch = "amd64"; |
569 |
#elif _X86_ |
|
570 |
sprops.os_arch = "x86"; |
|
571 |
#else |
|
572 |
sprops.os_arch = "unknown"; |
|
573 |
#endif |
|
574 |
} |
|
575 |
||
576 |
/* Endianness of platform */ |
|
577 |
{ |
|
578 |
unsigned int endianTest = 0xff000000; |
|
579 |
if (((char*)(&endianTest))[0] != 0) { |
|
580 |
sprops.cpu_endian = "big"; |
|
581 |
} else { |
|
582 |
sprops.cpu_endian = "little"; |
|
583 |
} |
|
584 |
} |
|
585 |
||
586 |
/* CPU ISA list */ |
|
587 |
sprops.cpu_isalist = cpu_isalist(); |
|
588 |
||
589 |
/* |
|
590 |
* User name |
|
591 |
* We try to avoid calling GetUserName as it turns out to |
|
592 |
* be surprisingly expensive on NT. It pulls in an extra |
|
593 |
* 100 K of footprint. |
|
594 |
*/ |
|
595 |
{ |
|
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
596 |
WCHAR *uname = _wgetenv(L"USERNAME"); |
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
597 |
if (uname != NULL && wcslen(uname) > 0) { |
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
598 |
sprops.user_name = _wcsdup(uname); |
2 | 599 |
} else { |
9027
540bd52f1881
7030249: Eliminate use of LoadLibrary and other clean-ups
alanb
parents:
7668
diff
changeset
|
600 |
DWORD buflen = 0; |
540bd52f1881
7030249: Eliminate use of LoadLibrary and other clean-ups
alanb
parents:
7668
diff
changeset
|
601 |
if (GetUserNameW(NULL, &buflen) == 0 && |
540bd52f1881
7030249: Eliminate use of LoadLibrary and other clean-ups
alanb
parents:
7668
diff
changeset
|
602 |
GetLastError() == ERROR_INSUFFICIENT_BUFFER) |
540bd52f1881
7030249: Eliminate use of LoadLibrary and other clean-ups
alanb
parents:
7668
diff
changeset
|
603 |
{ |
540bd52f1881
7030249: Eliminate use of LoadLibrary and other clean-ups
alanb
parents:
7668
diff
changeset
|
604 |
uname = (WCHAR*)malloc(buflen * sizeof(WCHAR)); |
540bd52f1881
7030249: Eliminate use of LoadLibrary and other clean-ups
alanb
parents:
7668
diff
changeset
|
605 |
if (uname != NULL && GetUserNameW(uname, &buflen) == 0) { |
540bd52f1881
7030249: Eliminate use of LoadLibrary and other clean-ups
alanb
parents:
7668
diff
changeset
|
606 |
free(uname); |
540bd52f1881
7030249: Eliminate use of LoadLibrary and other clean-ups
alanb
parents:
7668
diff
changeset
|
607 |
uname = NULL; |
540bd52f1881
7030249: Eliminate use of LoadLibrary and other clean-ups
alanb
parents:
7668
diff
changeset
|
608 |
} |
540bd52f1881
7030249: Eliminate use of LoadLibrary and other clean-ups
alanb
parents:
7668
diff
changeset
|
609 |
} else { |
540bd52f1881
7030249: Eliminate use of LoadLibrary and other clean-ups
alanb
parents:
7668
diff
changeset
|
610 |
uname = NULL; |
540bd52f1881
7030249: Eliminate use of LoadLibrary and other clean-ups
alanb
parents:
7668
diff
changeset
|
611 |
} |
540bd52f1881
7030249: Eliminate use of LoadLibrary and other clean-ups
alanb
parents:
7668
diff
changeset
|
612 |
sprops.user_name = (uname != NULL) ? uname : L"unknown"; |
2 | 613 |
} |
614 |
} |
|
615 |
||
616 |
/* |
|
15291 | 617 |
* Home directory |
2 | 618 |
* |
619 |
* The normal result is that for a given user name XXX: |
|
620 |
* On multi-user NT, user.home gets set to c:\winnt\profiles\XXX. |
|
621 |
* On multi-user Win95, user.home gets set to c:\windows\profiles\XXX. |
|
622 |
* On single-user Win95, user.home gets set to c:\windows. |
|
623 |
*/ |
|
624 |
{ |
|
15291 | 625 |
WCHAR *homep = getHomeFromShell32(); |
2 | 626 |
if (homep == NULL) { |
15291 | 627 |
homep = L"C:\\"; |
2 | 628 |
} |
15291 | 629 |
sprops.user_home = homep; |
2 | 630 |
} |
631 |
||
632 |
/* |
|
633 |
* user.language |
|
7017 | 634 |
* user.script, user.country, user.variant (if user's environment specifies them) |
2 | 635 |
* file.encoding |
636 |
*/ |
|
637 |
{ |
|
638 |
/* |
|
639 |
* query the system for the current system default locale |
|
640 |
* (which is a Windows LCID value), |
|
641 |
*/ |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
642 |
LCID userDefaultLCID = GetUserDefaultLCID(); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
643 |
LCID systemDefaultLCID = GetSystemDefaultLCID(); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
644 |
LCID userDefaultUILang = GetUserDefaultUILanguage(); |
2 | 645 |
|
646 |
{ |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
647 |
char * display_encoding; |
11906
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
648 |
HANDLE hStdOutErr; |
2 | 649 |
|
10338
ffaa7122547c
7073906: Locale.getDefault() returns wrong Locale for Java SE 7
naoto
parents:
9027
diff
changeset
|
650 |
// Windows UI Language selection list only cares "language" |
ffaa7122547c
7073906: Locale.getDefault() returns wrong Locale for Java SE 7
naoto
parents:
9027
diff
changeset
|
651 |
// information of the UI Language. For example, the list |
ffaa7122547c
7073906: Locale.getDefault() returns wrong Locale for Java SE 7
naoto
parents:
9027
diff
changeset
|
652 |
// just lists "English" but it actually means "en_US", and |
ffaa7122547c
7073906: Locale.getDefault() returns wrong Locale for Java SE 7
naoto
parents:
9027
diff
changeset
|
653 |
// the user cannot select "en_GB" (if exists) in the list. |
ffaa7122547c
7073906: Locale.getDefault() returns wrong Locale for Java SE 7
naoto
parents:
9027
diff
changeset
|
654 |
// So, this hack is to use the user LCID region information |
ffaa7122547c
7073906: Locale.getDefault() returns wrong Locale for Java SE 7
naoto
parents:
9027
diff
changeset
|
655 |
// for the UI Language, if the "language" portion of those |
ffaa7122547c
7073906: Locale.getDefault() returns wrong Locale for Java SE 7
naoto
parents:
9027
diff
changeset
|
656 |
// two locales are the same. |
ffaa7122547c
7073906: Locale.getDefault() returns wrong Locale for Java SE 7
naoto
parents:
9027
diff
changeset
|
657 |
if (PRIMARYLANGID(LANGIDFROMLCID(userDefaultLCID)) == |
ffaa7122547c
7073906: Locale.getDefault() returns wrong Locale for Java SE 7
naoto
parents:
9027
diff
changeset
|
658 |
PRIMARYLANGID(LANGIDFROMLCID(userDefaultUILang))) { |
ffaa7122547c
7073906: Locale.getDefault() returns wrong Locale for Java SE 7
naoto
parents:
9027
diff
changeset
|
659 |
userDefaultUILang = userDefaultLCID; |
ffaa7122547c
7073906: Locale.getDefault() returns wrong Locale for Java SE 7
naoto
parents:
9027
diff
changeset
|
660 |
} |
ffaa7122547c
7073906: Locale.getDefault() returns wrong Locale for Java SE 7
naoto
parents:
9027
diff
changeset
|
661 |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
662 |
SetupI18nProps(userDefaultLCID, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
663 |
&sprops.format_language, |
7017 | 664 |
&sprops.format_script, |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
665 |
&sprops.format_country, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
666 |
&sprops.format_variant, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
667 |
&sprops.encoding); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
668 |
SetupI18nProps(userDefaultUILang, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
669 |
&sprops.display_language, |
7017 | 670 |
&sprops.display_script, |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
671 |
&sprops.display_country, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
672 |
&sprops.display_variant, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
673 |
&display_encoding); |
2 | 674 |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
675 |
sprops.sun_jnu_encoding = getEncodingInternal(systemDefaultLCID); |
31246
dfc58fd4feec
8066504: GetVersionEx in java.base/windows/native/libjava/java_props_md.c might not get correct Windows version 0
rriggs
parents:
30784
diff
changeset
|
676 |
if (LANGIDFROMLCID(userDefaultLCID) == 0x0c04 && majorVersion == 6) { |
5167
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
3288
diff
changeset
|
677 |
// MS claims "Vista has built-in support for HKSCS-2004. |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
3288
diff
changeset
|
678 |
// All of the HKSCS-2004 characters have Unicode 4.1. |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
3288
diff
changeset
|
679 |
// PUA code point assignments". But what it really means |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
3288
diff
changeset
|
680 |
// is that the HKSCS-2004 is ONLY supported in Unicode. |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
3288
diff
changeset
|
681 |
// Test indicates the MS950 in its zh_HK locale is a |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
3288
diff
changeset
|
682 |
// "regular" MS950 which does not handle HKSCS-2004 at |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
3288
diff
changeset
|
683 |
// all. Set encoding to MS950_HKSCS. |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
3288
diff
changeset
|
684 |
sprops.encoding = "MS950_HKSCS"; |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
3288
diff
changeset
|
685 |
sprops.sun_jnu_encoding = "MS950_HKSCS"; |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
3288
diff
changeset
|
686 |
} |
11906
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
687 |
|
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
688 |
hStdOutErr = GetStdHandle(STD_OUTPUT_HANDLE); |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
689 |
if (hStdOutErr != INVALID_HANDLE_VALUE && |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
690 |
GetFileType(hStdOutErr) == FILE_TYPE_CHAR) { |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
691 |
sprops.sun_stdout_encoding = getConsoleEncoding(); |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
692 |
} |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
693 |
hStdOutErr = GetStdHandle(STD_ERROR_HANDLE); |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
694 |
if (hStdOutErr != INVALID_HANDLE_VALUE && |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
695 |
GetFileType(hStdOutErr) == FILE_TYPE_CHAR) { |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
696 |
if (sprops.sun_stdout_encoding != NULL) |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
697 |
sprops.sun_stderr_encoding = sprops.sun_stdout_encoding; |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
698 |
else |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
699 |
sprops.sun_stderr_encoding = getConsoleEncoding(); |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
700 |
} |
2 | 701 |
} |
702 |
} |
|
703 |
||
704 |
sprops.unicode_encoding = "UnicodeLittle"; |
|
52478
b915bd68d907
8185496: Improve performance of system properties initialization in initPhase1
rriggs
parents:
51943
diff
changeset
|
705 |
|
b915bd68d907
8185496: Improve performance of system properties initialization in initPhase1
rriggs
parents:
51943
diff
changeset
|
706 |
/* User TIMEZONE |
b915bd68d907
8185496: Improve performance of system properties initialization in initPhase1
rriggs
parents:
51943
diff
changeset
|
707 |
* We defer setting up timezone until it's actually necessary. |
b915bd68d907
8185496: Improve performance of system properties initialization in initPhase1
rriggs
parents:
51943
diff
changeset
|
708 |
* Refer to TimeZone.getDefault(). The system property |
b915bd68d907
8185496: Improve performance of system properties initialization in initPhase1
rriggs
parents:
51943
diff
changeset
|
709 |
* is able to be set by the command line interface -Duser.timezone. |
b915bd68d907
8185496: Improve performance of system properties initialization in initPhase1
rriggs
parents:
51943
diff
changeset
|
710 |
*/ |
2 | 711 |
|
712 |
/* Current directory */ |
|
713 |
{ |
|
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
714 |
WCHAR buf[MAX_PATH]; |
9027
540bd52f1881
7030249: Eliminate use of LoadLibrary and other clean-ups
alanb
parents:
7668
diff
changeset
|
715 |
if (GetCurrentDirectoryW(sizeof(buf)/sizeof(WCHAR), buf) != 0) |
540bd52f1881
7030249: Eliminate use of LoadLibrary and other clean-ups
alanb
parents:
7668
diff
changeset
|
716 |
sprops.user_dir = _wcsdup(buf); |
2 | 717 |
} |
718 |
||
719 |
sprops.file_separator = "\\"; |
|
720 |
sprops.path_separator = ";"; |
|
721 |
sprops.line_separator = "\r\n"; |
|
722 |
||
723 |
return &sprops; |
|
724 |
} |
|
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
725 |
|
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
726 |
jstring |
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
727 |
GetStringPlatform(JNIEnv *env, nchar* wcstr) |
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
728 |
{ |
30784 | 729 |
return (*env)->NewString(env, wcstr, (jsize)wcslen(wcstr)); |
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
730 |
} |