RFR: JDK-8266536: Provide a variant of os::iso8601_time which works with arbitrary timestamps [v3]

Xin Liu xliu at openjdk.java.net
Thu May 6 19:20:57 UTC 2021


On Thu, 6 May 2021 12:23:14 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

>> We have os::iso8601_time(), which gives an ISO8601 timestamp of the current time. It would be very useful to have a second variant which can be fed an arbitrary numerical timestamp.
>> 
>> This is useful in the context of making asynchronous UL logging cheaper (see JDK-8229517)
>> 
>> This patch provides an additional API: 
>> `char* os::iso8601_time(jlong milliseconds_since_19700101, char* buffer, size_t buffer_length, bool utc);`
>> alongside the existing
>> `char* os::iso8601_time(char* buffer, size_t buffer_length, bool utc);`
>> and implements the latter using the former. Not much code added.
>> 
>> In addition, it adds a regression gtest for these APIs.
>> 
>> Please ignore the harfbuzz change, its a build fix needed for older gcc, will be removed before final push.
>> 
>> Testing: GHA, manual gtests, SAP nightlies on all our platforms.
>> 
>> Thanks, Thomas
>
> Thomas Stuefe has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains seven additional commits since the last revision:
> 
>  - Merge
>  - remove harfbuzz fix
>  - Remove duplicate coding in gtest
>  - gtest for os.iso8601_time should use utc
>  - Build fix for Harfbuzz
>  - Merge
>  - start

src/hotspot/share/runtime/os.hpp line 231:

> 229:   // E.g., YYYY-MM-DDThh:mm:ss.mmm+zzzz.
> 230:   // Returns buffer, or NULL if it failed.
> 231:   static char* iso8601_time(jlong milliseconds_since_19700101, char buffer[29],

You are supposed to get a compiler warning on this char buffer[29]. ISO C/C++ can't pass in array type as a function argument.  As a result, the type buffer automatically casts to char* here. 

Further, the function signature is different from its implementation, which use char* buffer instead. 
I see that you do enforce length checking in implementation.

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

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


More information about the hotspot-runtime-dev mailing list