On Tue, 5 Jan 2021 01:31:28 GMT, Chris Plummer <cjplum...@openjdk.org> wrote:

> > jdk.hotspot.agent do not have `FormatMessage()` call in other place.
> > Did you say about whole JDK code? I haven't checked all of them, but some 
> > code (e.g. net_util_md.c) uses `JNU_ThrowByName()` which is provided by 
> > java.dll.
> 
> Yes, I was referring to all JDK code. Given how many references there are to 
> FormatMessage(), I'm surprised this issue has not turned up before. I was 
> wondering if there is something unique about the SA reference that makes the 
> issue only turn up there.

I looked at a cases in the JDK code where 
`Java_sun_security_pkcs11_wrapper_PKCS11_connect()` calls `FormatMessage()`. It 
eventually passes the `char*` to `jni_ThrowNew`, which eventually gets to 
`Exceptions::new_exception` with `to_utf8_safe==safe_to_utf8`. This means the 
message will be converted with `java_lang_String::create_from_str()`, which 
does NOT call `JNU_NewStringPlatform`. So I think in this case, the error 
message will also be garbled.

java.base/windows/native/libnet/Inet4AddressImpl.c seems to have a similar 
problem in the `ping4` function.

But, I don't know how to write a simple test case for the above.

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

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

Reply via email to