RFR: 8255239: The timezone of the hs_err_pid log file is corrupted in Japanese locale

Ioi Lam iklam at openjdk.java.net
Tue Nov 3 18:19:02 UTC 2020


On Tue, 3 Nov 2020 16:45:22 GMT, Ioi Lam <iklam at openjdk.org> wrote:

>> src/hotspot/share/runtime/os.cpp line 1006:
>> 
>>> 1004:   if (localtime_pd(&tloc, &tz) != NULL) {
>>> 1005:     wchar_t w_buf[80];
>>> 1006:     size_t n = ::wcsftime(w_buf, 80, L"%Z", &tz);
>> 
>> According to https://linux.die.net/man/3/wcsftime: "The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux."
>> 
>> Also, the L"%Z" notation is Windows-specific.
>> 
>> Maybe we should use the new code only on Windows?
>> 
>> An alternative is to use the C++ standard library (std::wcsftime and std:: wcstombs). However, this part of std:: is not yet permitted -- see https://bugs.openjdk.java.net/browse/JDK-8208089
>
> After further investigation -- wcsftime is in C99. Also, we use it here only inside `if (localtime_pd(&tloc, &tz) != NULL)`. I supposed any Linux distro that has a minimal of locale support to make that function return non-null would have a working implementation of wcsftime.
> 
> So I think this code is OK. The only change I request is to change ` L"%Z"` to `"%Z"`

Upon even more investigation, I was completely wrong :-)

According https://en.cppreference.com/w/cpp/language/string_literal, the "L" prefix is for `wchar_t` string literals. So your code is correct.

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

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


More information about the hotspot-runtime-dev mailing list