RFR: 8259045: Exception message from saproc.dll is garbled on Windows with Japanese locale

Yasumasa Suenaga ysuenaga at openjdk.java.net
Mon Jan 4 11:50:04 UTC 2021


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.

-------------

Commit messages:
 - 8259045: Exception message from saproc.dll is garbled on Windows with Japanese locale

Changes: https://git.openjdk.java.net/jdk/pull/1928/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=1928&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8259045
  Stats: 50 lines in 2 files changed: 4 ins; 37 del; 9 mod
  Patch: https://git.openjdk.java.net/jdk/pull/1928.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/1928/head:pull/1928

PR: https://git.openjdk.java.net/jdk/pull/1928



More information about the build-dev mailing list