author | rriggs |
Fri, 22 May 2015 10:12:18 -0400 | |
changeset 30784 | 28105f71beb2 |
parent 29116 | 9918719cfcc0 |
child 31246 | dfc58fd4feec |
permissions | -rw-r--r-- |
2 | 1 |
/* |
30784 | 2 |
* Copyright (c) 1998, 2015, 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 |
|
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
173 |
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
|
174 |
&(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
|
175 |
|
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
176 |
// 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
|
177 |
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
|
178 |
|
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
179 |
// 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
|
180 |
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
|
181 |
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
|
182 |
strcat(ret, "-"); |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
183 |
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
|
184 |
} |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
185 |
} |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
186 |
|
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
187 |
for (index = 0; index < 5; index++) { |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
188 |
free(elems[index]); |
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 |
|
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
195 |
return ret; |
2 | 196 |
} |
197 |
||
198 |
/* |
|
199 |
* Code to figure out the user's home directory using shell32.dll |
|
200 |
*/ |
|
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
201 |
WCHAR* |
2 | 202 |
getHomeFromShell32() |
203 |
{ |
|
15291 | 204 |
/* |
205 |
* Note that we don't free the memory allocated |
|
206 |
* by getHomeFromShell32. |
|
207 |
*/ |
|
208 |
static WCHAR *u_path = NULL; |
|
209 |
if (u_path == NULL) { |
|
210 |
HRESULT hr; |
|
2 | 211 |
|
15291 | 212 |
/* |
213 |
* SHELL32 DLL is delay load DLL and we can use the trick with |
|
214 |
* __try/__except block. |
|
215 |
*/ |
|
216 |
__try { |
|
217 |
/* |
|
218 |
* For Windows Vista and later (or patched MS OS) we need to use |
|
219 |
* [SHGetKnownFolderPath] call to avoid MAX_PATH length limitation. |
|
220 |
* Shell32.dll (version 6.0.6000 or later) |
|
221 |
*/ |
|
222 |
hr = SHGetKnownFolderPath(&FOLDERID_Profile, KF_FLAG_DONT_VERIFY, NULL, &u_path); |
|
223 |
} __except(EXCEPTION_EXECUTE_HANDLER) { |
|
224 |
/* Exception: no [SHGetKnownFolderPath] entry */ |
|
225 |
hr = E_FAIL; |
|
226 |
} |
|
2 | 227 |
|
15291 | 228 |
if (FAILED(hr)) { |
229 |
WCHAR path[MAX_PATH+1]; |
|
230 |
||
231 |
/* fallback solution for WinXP and Windows 2000 */ |
|
232 |
hr = SHGetFolderPathW(NULL, CSIDL_FLAG_DONT_VERIFY | CSIDL_PROFILE, NULL, SHGFP_TYPE_CURRENT, path); |
|
233 |
if (FAILED(hr)) { |
|
234 |
/* we can't find the shell folder. */ |
|
235 |
u_path = NULL; |
|
236 |
} else { |
|
237 |
/* Just to be sure about the path length until Windows Vista approach. |
|
238 |
* [S_FALSE] could not be returned due to [CSIDL_FLAG_DONT_VERIFY] flag and UNICODE version. |
|
239 |
*/ |
|
240 |
path[MAX_PATH] = 0; |
|
241 |
u_path = _wcsdup(path); |
|
242 |
} |
|
243 |
} |
|
244 |
} |
|
245 |
return u_path; |
|
2 | 246 |
} |
247 |
||
248 |
static boolean |
|
249 |
haveMMX(void) |
|
250 |
{ |
|
9027
540bd52f1881
7030249: Eliminate use of LoadLibrary and other clean-ups
alanb
parents:
7668
diff
changeset
|
251 |
return IsProcessorFeaturePresent(PF_MMX_INSTRUCTIONS_AVAILABLE); |
2 | 252 |
} |
253 |
||
254 |
static const char * |
|
255 |
cpu_isalist(void) |
|
256 |
{ |
|
257 |
SYSTEM_INFO info; |
|
258 |
GetSystemInfo(&info); |
|
259 |
switch (info.wProcessorArchitecture) { |
|
260 |
#ifdef PROCESSOR_ARCHITECTURE_IA64 |
|
261 |
case PROCESSOR_ARCHITECTURE_IA64: return "ia64"; |
|
262 |
#endif |
|
263 |
#ifdef PROCESSOR_ARCHITECTURE_AMD64 |
|
264 |
case PROCESSOR_ARCHITECTURE_AMD64: return "amd64"; |
|
265 |
#endif |
|
266 |
case PROCESSOR_ARCHITECTURE_INTEL: |
|
267 |
switch (info.wProcessorLevel) { |
|
268 |
case 6: return haveMMX() |
|
269 |
? "pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86" |
|
270 |
: "pentium_pro pentium i486 i386 i86"; |
|
271 |
case 5: return haveMMX() |
|
272 |
? "pentium+mmx pentium i486 i386 i86" |
|
273 |
: "pentium i486 i386 i86"; |
|
274 |
case 4: return "i486 i386 i86"; |
|
275 |
case 3: return "i386 i86"; |
|
276 |
} |
|
277 |
} |
|
278 |
return NULL; |
|
279 |
} |
|
280 |
||
22939
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
281 |
static boolean |
7017 | 282 |
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
|
283 |
char** variant, char** encoding) { |
7017 | 284 |
/* script */ |
285 |
char tmp[SNAMESIZE]; |
|
286 |
*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
|
287 |
if (*script == NULL) { |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
288 |
return FALSE; |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
289 |
} |
7017 | 290 |
if (GetLocaleInfo(lcid, |
291 |
LOCALE_SNAME, tmp, SNAMESIZE) == 0 || |
|
292 |
sscanf(tmp, "%*[a-z\\-]%1[A-Z]%[a-z]", *script, &((*script)[1])) == 0 || |
|
293 |
strlen(*script) != 4) { |
|
294 |
(*script)[0] = '\0'; |
|
295 |
} |
|
296 |
||
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
297 |
/* country */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
298 |
*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
|
299 |
if (*country == NULL) { |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
300 |
return FALSE; |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
301 |
} |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
302 |
if (GetLocaleInfo(lcid, |
7017 | 303 |
LOCALE_SISO3166CTRYNAME, *country, PROPSIZE) == 0 && |
304 |
GetLocaleInfo(lcid, |
|
305 |
LOCALE_SISO3166CTRYNAME2, *country, PROPSIZE) == 0) { |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
306 |
(*country)[0] = '\0'; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
307 |
} |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
308 |
|
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
309 |
/* language */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
310 |
*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
|
311 |
if (*language == NULL) { |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
312 |
return FALSE; |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
313 |
} |
7017 | 314 |
if (GetLocaleInfo(lcid, |
315 |
LOCALE_SISO639LANGNAME, *language, PROPSIZE) == 0 && |
|
316 |
GetLocaleInfo(lcid, |
|
317 |
LOCALE_SISO639LANGNAME2, *language, PROPSIZE) == 0) { |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
318 |
/* defaults to en_US */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
319 |
strcpy(*language, "en"); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
320 |
strcpy(*country, "US"); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
321 |
} |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
322 |
|
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
323 |
/* variant */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
324 |
*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
|
325 |
if (*variant == NULL) { |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
326 |
return FALSE; |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
327 |
} |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
328 |
(*variant)[0] = '\0'; |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
329 |
|
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
330 |
/* handling for Norwegian */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
331 |
if (strcmp(*language, "nb") == 0) { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
332 |
strcpy(*language, "no"); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
333 |
strcpy(*country , "NO"); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
334 |
} else if (strcmp(*language, "nn") == 0) { |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
335 |
strcpy(*language, "no"); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
336 |
strcpy(*country , "NO"); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
337 |
strcpy(*variant, "NY"); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
338 |
} |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
339 |
|
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
340 |
/* encoding */ |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
341 |
*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
|
342 |
if (*encoding == NULL) { |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
343 |
return FALSE; |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
344 |
} |
fc08f20ea32f
8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending
naoto
parents:
19190
diff
changeset
|
345 |
return TRUE; |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
346 |
} |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
347 |
|
30784 | 348 |
// GetVersionEx is deprecated; disable the warning until a replacement is found |
349 |
#pragma warning(disable : 4996) |
|
2 | 350 |
java_props_t * |
351 |
GetJavaProperties(JNIEnv* env) |
|
352 |
{ |
|
353 |
static java_props_t sprops = {0}; |
|
354 |
||
5167
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
3288
diff
changeset
|
355 |
OSVERSIONINFOEX ver; |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
3288
diff
changeset
|
356 |
|
15291 | 357 |
if (sprops.line_separator) { |
2 | 358 |
return &sprops; |
359 |
} |
|
360 |
||
361 |
/* AWT properties */ |
|
362 |
sprops.awt_toolkit = "sun.awt.windows.WToolkit"; |
|
363 |
||
364 |
/* tmp dir */ |
|
365 |
{ |
|
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
366 |
WCHAR tmpdir[MAX_PATH + 1]; |
2 | 367 |
/* 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
|
368 |
GetTempPathW(MAX_PATH + 1, tmpdir); |
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
369 |
sprops.tmp_dir = _wcsdup(tmpdir); |
2 | 370 |
} |
371 |
||
372 |
/* Printing properties */ |
|
373 |
sprops.printerJob = "sun.awt.windows.WPrinterJob"; |
|
374 |
||
375 |
/* Java2D properties */ |
|
376 |
sprops.graphics_env = "sun.awt.Win32GraphicsEnvironment"; |
|
377 |
||
378 |
{ /* This is used only for debugging of font problems. */ |
|
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
379 |
WCHAR *path = _wgetenv(L"JAVA2D_FONTPATH"); |
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
380 |
sprops.font_dir = (path != NULL) ? _wcsdup(path) : NULL; |
2 | 381 |
} |
382 |
||
383 |
/* OS properties */ |
|
384 |
{ |
|
385 |
char buf[100]; |
|
1626
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
386 |
SYSTEM_INFO si; |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
387 |
PGNSI pGNSI; |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
388 |
|
2 | 389 |
ver.dwOSVersionInfoSize = sizeof(ver); |
49
b25b3ff21b7c
6642034: System.getProperty("os.name") returns Windows Vista on Windows Server 2008 (longhorn)
martin
parents:
2
diff
changeset
|
390 |
GetVersionEx((OSVERSIONINFO *) &ver); |
2 | 391 |
|
1626
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
392 |
ZeroMemory(&si, sizeof(SYSTEM_INFO)); |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
393 |
// Call GetNativeSystemInfo if supported or GetSystemInfo otherwise. |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
394 |
pGNSI = (PGNSI) GetProcAddress( |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
395 |
GetModuleHandle(TEXT("kernel32.dll")), |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
396 |
"GetNativeSystemInfo"); |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
397 |
if(NULL != pGNSI) |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
398 |
pGNSI(&si); |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
399 |
else |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
400 |
GetSystemInfo(&si); |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
401 |
|
2 | 402 |
/* |
403 |
* 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
|
404 |
* writing, decoding of dwMajorVersion and dwMinorVersion. |
2 | 405 |
* |
406 |
* Operating system dwMajorVersion dwMinorVersion |
|
407 |
* ================== ============== ============== |
|
408 |
* |
|
409 |
* Windows 95 4 0 |
|
410 |
* Windows 98 4 10 |
|
411 |
* Windows ME 4 90 |
|
412 |
* Windows 3.51 3 51 |
|
413 |
* Windows NT 4.0 4 0 |
|
414 |
* Windows 2000 5 0 |
|
1626
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
415 |
* Windows XP 32 bit 5 1 |
2 | 416 |
* 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
|
417 |
* 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
|
418 |
* where ((&ver.wServicePackMinor) + 2) = 1 |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
419 |
* and si.wProcessorArchitecture = 9 |
3212 | 420 |
* Windows Vista family 6 0 (VER_NT_WORKSTATION) |
421 |
* Windows Server 2008 6 0 (!VER_NT_WORKSTATION) |
|
422 |
* Windows 7 6 1 (VER_NT_WORKSTATION) |
|
423 |
* 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
|
424 |
* 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
|
425 |
* Windows Server 2012 6 2 (!VER_NT_WORKSTATION) |
2 | 426 |
* |
427 |
* This mapping will presumably be augmented as new Windows |
|
428 |
* versions are released. |
|
429 |
*/ |
|
430 |
switch (ver.dwPlatformId) { |
|
431 |
case VER_PLATFORM_WIN32s: |
|
432 |
sprops.os_name = "Windows 3.1"; |
|
433 |
break; |
|
434 |
case VER_PLATFORM_WIN32_WINDOWS: |
|
435 |
if (ver.dwMajorVersion == 4) { |
|
436 |
switch (ver.dwMinorVersion) { |
|
437 |
case 0: sprops.os_name = "Windows 95"; break; |
|
438 |
case 10: sprops.os_name = "Windows 98"; break; |
|
439 |
case 90: sprops.os_name = "Windows Me"; break; |
|
440 |
default: sprops.os_name = "Windows 9X (unknown)"; break; |
|
441 |
} |
|
442 |
} else { |
|
443 |
sprops.os_name = "Windows 9X (unknown)"; |
|
444 |
} |
|
445 |
break; |
|
446 |
case VER_PLATFORM_WIN32_NT: |
|
447 |
if (ver.dwMajorVersion <= 4) { |
|
448 |
sprops.os_name = "Windows NT"; |
|
449 |
} else if (ver.dwMajorVersion == 5) { |
|
450 |
switch (ver.dwMinorVersion) { |
|
451 |
case 0: sprops.os_name = "Windows 2000"; break; |
|
452 |
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
|
453 |
case 2: |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
454 |
/* |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
455 |
* 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
|
456 |
* |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
457 |
* "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
|
458 |
* 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
|
459 |
* 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
|
460 |
* and si.wProcessorArchitecture is |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
461 |
* 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
|
462 |
* 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
|
463 |
* 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
|
464 |
*/ |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
465 |
if(ver.wProductType == VER_NT_WORKSTATION && |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
466 |
si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) { |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
467 |
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
|
468 |
} else { |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
469 |
sprops.os_name = "Windows 2003"; |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
470 |
} |
e1c6dff266e5
6714428: 'os.name' system property shows wrong value on 64-bit Windows XP
sherman
parents:
715
diff
changeset
|
471 |
break; |
2 | 472 |
default: sprops.os_name = "Windows NT (unknown)"; break; |
473 |
} |
|
474 |
} else if (ver.dwMajorVersion == 6) { |
|
49
b25b3ff21b7c
6642034: System.getProperty("os.name") returns Windows Vista on Windows Server 2008 (longhorn)
martin
parents:
2
diff
changeset
|
475 |
/* |
3212 | 476 |
* 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
|
477 |
*/ |
2424
3663fccf2fc3
6819886: System.getProperty("os.name") reports Vista on Windows 7
alanb
parents:
1626
diff
changeset
|
478 |
if (ver.wProductType == VER_NT_WORKSTATION) { |
3663fccf2fc3
6819886: System.getProperty("os.name") reports Vista on Windows 7
alanb
parents:
1626
diff
changeset
|
479 |
switch (ver.dwMinorVersion) { |
3663fccf2fc3
6819886: System.getProperty("os.name") reports Vista on Windows 7
alanb
parents:
1626
diff
changeset
|
480 |
case 0: sprops.os_name = "Windows Vista"; break; |
3663fccf2fc3
6819886: System.getProperty("os.name") reports Vista on Windows 7
alanb
parents:
1626
diff
changeset
|
481 |
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
|
482 |
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
|
483 |
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
|
484 |
default: sprops.os_name = "Windows NT (unknown)"; |
3663fccf2fc3
6819886: System.getProperty("os.name") reports Vista on Windows 7
alanb
parents:
1626
diff
changeset
|
485 |
} |
3663fccf2fc3
6819886: System.getProperty("os.name") reports Vista on Windows 7
alanb
parents:
1626
diff
changeset
|
486 |
} else { |
3212 | 487 |
switch (ver.dwMinorVersion) { |
488 |
case 0: sprops.os_name = "Windows Server 2008"; break; |
|
489 |
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
|
490 |
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
|
491 |
case 3: sprops.os_name = "Windows Server 2012 R2"; break; |
3212 | 492 |
default: sprops.os_name = "Windows NT (unknown)"; |
493 |
} |
|
2424
3663fccf2fc3
6819886: System.getProperty("os.name") reports Vista on Windows 7
alanb
parents:
1626
diff
changeset
|
494 |
} |
2 | 495 |
} else { |
496 |
sprops.os_name = "Windows NT (unknown)"; |
|
497 |
} |
|
498 |
break; |
|
499 |
default: |
|
500 |
sprops.os_name = "Windows (unknown)"; |
|
501 |
break; |
|
502 |
} |
|
503 |
sprintf(buf, "%d.%d", ver.dwMajorVersion, ver.dwMinorVersion); |
|
6850
56966b0a6a0d
6989466: Miscellaneous compiler warnings in java/lang, java/util, java/io, sun/misc native code
alanb
parents:
6489
diff
changeset
|
504 |
sprops.os_version = _strdup(buf); |
2 | 505 |
#if _M_IA64 |
506 |
sprops.os_arch = "ia64"; |
|
507 |
#elif _M_AMD64 |
|
508 |
sprops.os_arch = "amd64"; |
|
509 |
#elif _X86_ |
|
510 |
sprops.os_arch = "x86"; |
|
511 |
#else |
|
512 |
sprops.os_arch = "unknown"; |
|
513 |
#endif |
|
514 |
||
6850
56966b0a6a0d
6989466: Miscellaneous compiler warnings in java/lang, java/util, java/io, sun/misc native code
alanb
parents:
6489
diff
changeset
|
515 |
sprops.patch_level = _strdup(ver.szCSDVersion); |
2 | 516 |
|
517 |
sprops.desktop = "windows"; |
|
518 |
} |
|
519 |
||
520 |
/* Endianness of platform */ |
|
521 |
{ |
|
522 |
unsigned int endianTest = 0xff000000; |
|
523 |
if (((char*)(&endianTest))[0] != 0) { |
|
524 |
sprops.cpu_endian = "big"; |
|
525 |
} else { |
|
526 |
sprops.cpu_endian = "little"; |
|
527 |
} |
|
528 |
} |
|
529 |
||
530 |
/* CPU ISA list */ |
|
531 |
sprops.cpu_isalist = cpu_isalist(); |
|
532 |
||
533 |
/* |
|
534 |
* User name |
|
535 |
* We try to avoid calling GetUserName as it turns out to |
|
536 |
* be surprisingly expensive on NT. It pulls in an extra |
|
537 |
* 100 K of footprint. |
|
538 |
*/ |
|
539 |
{ |
|
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
540 |
WCHAR *uname = _wgetenv(L"USERNAME"); |
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
541 |
if (uname != NULL && wcslen(uname) > 0) { |
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
542 |
sprops.user_name = _wcsdup(uname); |
2 | 543 |
} else { |
9027
540bd52f1881
7030249: Eliminate use of LoadLibrary and other clean-ups
alanb
parents:
7668
diff
changeset
|
544 |
DWORD buflen = 0; |
540bd52f1881
7030249: Eliminate use of LoadLibrary and other clean-ups
alanb
parents:
7668
diff
changeset
|
545 |
if (GetUserNameW(NULL, &buflen) == 0 && |
540bd52f1881
7030249: Eliminate use of LoadLibrary and other clean-ups
alanb
parents:
7668
diff
changeset
|
546 |
GetLastError() == ERROR_INSUFFICIENT_BUFFER) |
540bd52f1881
7030249: Eliminate use of LoadLibrary and other clean-ups
alanb
parents:
7668
diff
changeset
|
547 |
{ |
540bd52f1881
7030249: Eliminate use of LoadLibrary and other clean-ups
alanb
parents:
7668
diff
changeset
|
548 |
uname = (WCHAR*)malloc(buflen * sizeof(WCHAR)); |
540bd52f1881
7030249: Eliminate use of LoadLibrary and other clean-ups
alanb
parents:
7668
diff
changeset
|
549 |
if (uname != NULL && GetUserNameW(uname, &buflen) == 0) { |
540bd52f1881
7030249: Eliminate use of LoadLibrary and other clean-ups
alanb
parents:
7668
diff
changeset
|
550 |
free(uname); |
540bd52f1881
7030249: Eliminate use of LoadLibrary and other clean-ups
alanb
parents:
7668
diff
changeset
|
551 |
uname = NULL; |
540bd52f1881
7030249: Eliminate use of LoadLibrary and other clean-ups
alanb
parents:
7668
diff
changeset
|
552 |
} |
540bd52f1881
7030249: Eliminate use of LoadLibrary and other clean-ups
alanb
parents:
7668
diff
changeset
|
553 |
} else { |
540bd52f1881
7030249: Eliminate use of LoadLibrary and other clean-ups
alanb
parents:
7668
diff
changeset
|
554 |
uname = NULL; |
540bd52f1881
7030249: Eliminate use of LoadLibrary and other clean-ups
alanb
parents:
7668
diff
changeset
|
555 |
} |
540bd52f1881
7030249: Eliminate use of LoadLibrary and other clean-ups
alanb
parents:
7668
diff
changeset
|
556 |
sprops.user_name = (uname != NULL) ? uname : L"unknown"; |
2 | 557 |
} |
558 |
} |
|
559 |
||
560 |
/* |
|
15291 | 561 |
* Home directory |
2 | 562 |
* |
563 |
* The normal result is that for a given user name XXX: |
|
564 |
* On multi-user NT, user.home gets set to c:\winnt\profiles\XXX. |
|
565 |
* On multi-user Win95, user.home gets set to c:\windows\profiles\XXX. |
|
566 |
* On single-user Win95, user.home gets set to c:\windows. |
|
567 |
*/ |
|
568 |
{ |
|
15291 | 569 |
WCHAR *homep = getHomeFromShell32(); |
2 | 570 |
if (homep == NULL) { |
15291 | 571 |
homep = L"C:\\"; |
2 | 572 |
} |
15291 | 573 |
sprops.user_home = homep; |
2 | 574 |
} |
575 |
||
576 |
/* |
|
577 |
* user.language |
|
7017 | 578 |
* user.script, user.country, user.variant (if user's environment specifies them) |
2 | 579 |
* file.encoding |
580 |
* file.encoding.pkg |
|
581 |
*/ |
|
582 |
{ |
|
583 |
/* |
|
584 |
* query the system for the current system default locale |
|
585 |
* (which is a Windows LCID value), |
|
586 |
*/ |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
587 |
LCID userDefaultLCID = GetUserDefaultLCID(); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
588 |
LCID systemDefaultLCID = GetSystemDefaultLCID(); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
589 |
LCID userDefaultUILang = GetUserDefaultUILanguage(); |
2 | 590 |
|
591 |
{ |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
592 |
char * display_encoding; |
11906
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
593 |
HANDLE hStdOutErr; |
2 | 594 |
|
10338
ffaa7122547c
7073906: Locale.getDefault() returns wrong Locale for Java SE 7
naoto
parents:
9027
diff
changeset
|
595 |
// Windows UI Language selection list only cares "language" |
ffaa7122547c
7073906: Locale.getDefault() returns wrong Locale for Java SE 7
naoto
parents:
9027
diff
changeset
|
596 |
// 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
|
597 |
// 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
|
598 |
// 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
|
599 |
// 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
|
600 |
// 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
|
601 |
// two locales are the same. |
ffaa7122547c
7073906: Locale.getDefault() returns wrong Locale for Java SE 7
naoto
parents:
9027
diff
changeset
|
602 |
if (PRIMARYLANGID(LANGIDFROMLCID(userDefaultLCID)) == |
ffaa7122547c
7073906: Locale.getDefault() returns wrong Locale for Java SE 7
naoto
parents:
9027
diff
changeset
|
603 |
PRIMARYLANGID(LANGIDFROMLCID(userDefaultUILang))) { |
ffaa7122547c
7073906: Locale.getDefault() returns wrong Locale for Java SE 7
naoto
parents:
9027
diff
changeset
|
604 |
userDefaultUILang = userDefaultLCID; |
ffaa7122547c
7073906: Locale.getDefault() returns wrong Locale for Java SE 7
naoto
parents:
9027
diff
changeset
|
605 |
} |
ffaa7122547c
7073906: Locale.getDefault() returns wrong Locale for Java SE 7
naoto
parents:
9027
diff
changeset
|
606 |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
607 |
SetupI18nProps(userDefaultUILang, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
608 |
&sprops.language, |
7017 | 609 |
&sprops.script, |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
610 |
&sprops.country, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
611 |
&sprops.variant, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
612 |
&display_encoding); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
613 |
SetupI18nProps(userDefaultLCID, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
614 |
&sprops.format_language, |
7017 | 615 |
&sprops.format_script, |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
616 |
&sprops.format_country, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
617 |
&sprops.format_variant, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
618 |
&sprops.encoding); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
619 |
SetupI18nProps(userDefaultUILang, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
620 |
&sprops.display_language, |
7017 | 621 |
&sprops.display_script, |
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
622 |
&sprops.display_country, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
623 |
&sprops.display_variant, |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
624 |
&display_encoding); |
2 | 625 |
|
6489
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
626 |
sprops.sun_jnu_encoding = getEncodingInternal(systemDefaultLCID); |
9e7015635425
4700857: RFE: separating user locale and user interface locale
naoto
parents:
5506
diff
changeset
|
627 |
if (LANGIDFROMLCID(userDefaultLCID) == 0x0c04 && ver.dwMajorVersion == 6) { |
5167
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
3288
diff
changeset
|
628 |
// 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
|
629 |
// 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
|
630 |
// 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
|
631 |
// 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
|
632 |
// 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
|
633 |
// "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
|
634 |
// all. Set encoding to MS950_HKSCS. |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
3288
diff
changeset
|
635 |
sprops.encoding = "MS950_HKSCS"; |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
3288
diff
changeset
|
636 |
sprops.sun_jnu_encoding = "MS950_HKSCS"; |
dbd299f8fdae
6902790: Converting/displaying HKSCs characters issue on Vista and Windows7
sherman
parents:
3288
diff
changeset
|
637 |
} |
11906
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
638 |
|
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
639 |
hStdOutErr = GetStdHandle(STD_OUTPUT_HANDLE); |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
640 |
if (hStdOutErr != INVALID_HANDLE_VALUE && |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
641 |
GetFileType(hStdOutErr) == FILE_TYPE_CHAR) { |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
642 |
sprops.sun_stdout_encoding = getConsoleEncoding(); |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
643 |
} |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
644 |
hStdOutErr = GetStdHandle(STD_ERROR_HANDLE); |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
645 |
if (hStdOutErr != INVALID_HANDLE_VALUE && |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
646 |
GetFileType(hStdOutErr) == FILE_TYPE_CHAR) { |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
647 |
if (sprops.sun_stdout_encoding != NULL) |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
648 |
sprops.sun_stderr_encoding = sprops.sun_stdout_encoding; |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
649 |
else |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
650 |
sprops.sun_stderr_encoding = getConsoleEncoding(); |
dc984e35d8a6
4153167: separate between ANSI and OEM code pages on Windows
sherman
parents:
10338
diff
changeset
|
651 |
} |
2 | 652 |
} |
653 |
} |
|
654 |
||
655 |
sprops.unicode_encoding = "UnicodeLittle"; |
|
656 |
/* User TIMEZONE */ |
|
657 |
{ |
|
658 |
/* |
|
659 |
* We defer setting up timezone until it's actually necessary. |
|
660 |
* Refer to TimeZone.getDefault(). However, the system |
|
661 |
* property is necessary to be able to be set by the command |
|
662 |
* line interface -D. Here temporarily set a null string to |
|
663 |
* timezone. |
|
664 |
*/ |
|
665 |
sprops.timezone = ""; |
|
666 |
} |
|
667 |
||
668 |
/* Current directory */ |
|
669 |
{ |
|
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
670 |
WCHAR buf[MAX_PATH]; |
9027
540bd52f1881
7030249: Eliminate use of LoadLibrary and other clean-ups
alanb
parents:
7668
diff
changeset
|
671 |
if (GetCurrentDirectoryW(sizeof(buf)/sizeof(WCHAR), buf) != 0) |
540bd52f1881
7030249: Eliminate use of LoadLibrary and other clean-ups
alanb
parents:
7668
diff
changeset
|
672 |
sprops.user_dir = _wcsdup(buf); |
2 | 673 |
} |
674 |
||
675 |
sprops.file_separator = "\\"; |
|
676 |
sprops.path_separator = ";"; |
|
677 |
sprops.line_separator = "\r\n"; |
|
678 |
||
679 |
return &sprops; |
|
680 |
} |
|
5168
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
681 |
|
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
682 |
jstring |
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
683 |
GetStringPlatform(JNIEnv *env, nchar* wcstr) |
41e46b5d9b15
4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents:
5167
diff
changeset
|
684 |
{ |
30784 | 685 |
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
|
686 |
} |