8242283: Can't start JVM when java home path includes non-ASCII character

Reviewed-by: naoto, hseigel
This commit is contained in:
Yasumasa Suenaga 2020-04-14 09:03:38 +09:00
parent 4a09f31eff
commit d34f732b99
5 changed files with 11 additions and 11 deletions
src
hotspot/os/windows
java.base
share/native/libzip
windows/native
jdk.incubator.jpackage/windows/native/libapplauncher

@ -4143,7 +4143,7 @@ static void file_attribute_data_to_stat(struct stat* sbuf, WIN32_FILE_ATTRIBUTE_
static errno_t convert_to_unicode(char const* char_path, LPWSTR* unicode_path) {
// Get required buffer size to convert to Unicode
int unicode_path_len = MultiByteToWideChar(CP_THREAD_ACP,
int unicode_path_len = MultiByteToWideChar(CP_ACP,
MB_ERR_INVALID_CHARS,
char_path, -1,
NULL, 0);
@ -4153,7 +4153,7 @@ static errno_t convert_to_unicode(char const* char_path, LPWSTR* unicode_path) {
*unicode_path = NEW_C_HEAP_ARRAY(WCHAR, unicode_path_len, mtInternal);
int result = MultiByteToWideChar(CP_THREAD_ACP,
int result = MultiByteToWideChar(CP_ACP,
MB_ERR_INVALID_CHARS,
char_path, -1,
*unicode_path, unicode_path_len);

@ -136,7 +136,7 @@ ZFILE_Open(const char *fname, int flags) {
NULL);
} else {
/* Get required buffer size to convert to Unicode */
int wfname_len = MultiByteToWideChar(CP_THREAD_ACP, MB_ERR_INVALID_CHARS,
int wfname_len = MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS,
fname, -1, NULL, 0);
if (wfname_len == 0) {
return (jlong)INVALID_HANDLE_VALUE;
@ -144,7 +144,7 @@ ZFILE_Open(const char *fname, int flags) {
if ((wfname = (WCHAR*)malloc(wfname_len * sizeof(WCHAR))) == NULL) {
return (jlong)INVALID_HANDLE_VALUE;
}
if (MultiByteToWideChar(CP_THREAD_ACP, MB_ERR_INVALID_CHARS,
if (MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS,
fname, -1, wfname, wfname_len) == 0) {
free(wfname);
return (jlong)INVALID_HANDLE_VALUE;

@ -334,7 +334,7 @@ JDK_Canonicalize(const char *orig, char *out, int len) {
int ret = -1;
/* Get required buffer size to convert to Unicode */
wpath_len = MultiByteToWideChar(CP_THREAD_ACP, MB_ERR_INVALID_CHARS,
wpath_len = MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS,
orig, -1, NULL, 0);
if (wpath_len == 0) {
goto finish;
@ -344,7 +344,7 @@ JDK_Canonicalize(const char *orig, char *out, int len) {
goto finish;
}
if (MultiByteToWideChar(CP_THREAD_ACP, MB_ERR_INVALID_CHARS,
if (MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS,
orig, -1, wpath, wpath_len) == 0) {
goto finish;
}
@ -357,7 +357,7 @@ JDK_Canonicalize(const char *orig, char *out, int len) {
goto finish;
}
if (WideCharToMultiByte(CP_THREAD_ACP, 0,
if (WideCharToMultiByte(CP_ACP, 0,
wresult, -1, out, len, NULL, NULL) == 0) {
goto finish;
}

@ -504,7 +504,7 @@ static errno_t convert_to_unicode(const char* path, const wchar_t* prefix, wchar
* Get required buffer size to convert to Unicode.
* The return value includes the terminating null character.
*/
unicode_path_len = MultiByteToWideChar(CP_THREAD_ACP, MB_ERR_INVALID_CHARS,
unicode_path_len = MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS,
path, -1, NULL, 0);
if (unicode_path_len == 0) {
return EINVAL;
@ -518,7 +518,7 @@ static errno_t convert_to_unicode(const char* path, const wchar_t* prefix, wchar
}
wcsncpy(*wpath, prefix, prefix_len);
if (MultiByteToWideChar(CP_THREAD_ACP, MB_ERR_INVALID_CHARS,
if (MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS,
path, -1, &((*wpath)[prefix_len]), (int)wpath_len) == 0) {
JLI_MemFree(*wpath);
*wpath = NULL;

@ -404,12 +404,12 @@ WideString Platform::MultibyteStringToWideString(const char* value) {
return result;
}
count = MultiByteToWideChar(CP_THREAD_ACP, MB_ERR_INVALID_CHARS,
count = MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS,
value, -1, NULL, 0);
if (count > 0) {
result.data = new wchar_t[count];
result.length = MultiByteToWideChar(CP_THREAD_ACP, MB_ERR_INVALID_CHARS,
result.length = MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS,
value, -1, result.data, (int)count);
if (result.length == 0) {
delete[] result.data;