mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 19:14:38 +02:00
8232846: ProcessHandle.Info command with non-English shows question marks
Reviewed-by: stuefe, ysuenaga, rriggs
This commit is contained in:
parent
253ccad50a
commit
7f8d785086
1 changed files with 21 additions and 9 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -469,16 +469,28 @@ static void getStatInfo(JNIEnv *env, HANDLE handle, jobject jinfo) {
|
|||
}
|
||||
|
||||
static void getCmdlineInfo(JNIEnv *env, HANDLE handle, jobject jinfo) {
|
||||
char exeName[1024];
|
||||
int bufsize = sizeof exeName;
|
||||
jstring commandObj;
|
||||
WCHAR exeName[1024];
|
||||
WCHAR *longPath;
|
||||
DWORD bufsize = sizeof(exeName)/sizeof(WCHAR);
|
||||
jstring commandObj = NULL;
|
||||
|
||||
if (QueryFullProcessImageName(handle, 0, exeName, &bufsize)) {
|
||||
commandObj = (*env)->NewStringUTF(env, exeName);
|
||||
CHECK_NULL(commandObj);
|
||||
(*env)->SetObjectField(env, jinfo,
|
||||
ProcessHandleImpl_Info_commandID, commandObj);
|
||||
if (QueryFullProcessImageNameW(handle, 0, exeName, &bufsize)) {
|
||||
commandObj = (*env)->NewString(env, (const jchar *)exeName,
|
||||
(jsize)wcslen(exeName));
|
||||
} else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
|
||||
bufsize = 32768;
|
||||
longPath = (WCHAR*)malloc(bufsize * sizeof(WCHAR));
|
||||
if (longPath != NULL) {
|
||||
if (QueryFullProcessImageNameW(handle, 0, longPath, &bufsize)) {
|
||||
commandObj = (*env)->NewString(env, (const jchar *)longPath,
|
||||
(jsize)wcslen(longPath));
|
||||
}
|
||||
free(longPath);
|
||||
}
|
||||
}
|
||||
CHECK_NULL(commandObj);
|
||||
(*env)->SetObjectField(env, jinfo,
|
||||
ProcessHandleImpl_Info_commandID, commandObj);
|
||||
}
|
||||
|
||||
static void procToUser(JNIEnv *env, HANDLE handle, jobject jinfo) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue