RFR: 8259045: Exception message from saproc.dll is garbled on Windows with Japanese locale
Yasumasa Suenaga
ysuenaga at openjdk.java.net
Tue Jan 5 00:32:02 UTC 2021
On Mon, 4 Jan 2021 20:58:59 GMT, Chris Plummer <cjplummer at openjdk.org> wrote:
>> I got garbled exception message as following when I run `livenmethods` CLHSDB command:
>>
>> sun.jvm.hotspot.debugger.DebuggerException : ?w???????W
>>
>> My Windows laptop is set Japanese Locale, garbled message was written in Japanese.
>> saproc.dll would throw exception via [ThrowNew()](https://docs.oracle.com/en/java/javase/15/docs/specs/jni/functions.html#thrownew) JNI function, but it accepts UTF-8 encoded message. However [FormatMessage()](https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-formatmessage) Windows API might not return UTF-8 encoded string on Japanese locale.
>>
>> java.dll (libjava,so) provides good functions to resolve this issue. We can convert localized (non ascii) chars to UTF-8 string. I use them in this PR and remove `FormatMessage()` call from sadis.c.
>> And also I remove `-D_MBCS` from compiler option because [MBCS has been already deprecated](https://docs.microsoft.com/ja-jp/cpp/text/support-for-multibyte-character-sets-mbcss) - it does not seem to add to any other executables.
>
> src/jdk.hotspot.agent/share/native/libsaproc/sadis.c line 75:
>
>> 73:
>> 74: #ifdef _WINDOWS
>> 75: static int getLastErrorString(char *buf, size_t len)
>
> Is this being removed because a copy already exists in jni_util_md.c, and you now have access to this copy because you are linking against java.dll?
Exactly.
-------------
PR: https://git.openjdk.java.net/jdk/pull/1928
More information about the build-dev
mailing list