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

Thomas Stuefe stuefe at openjdk.java.net
Thu May 6 09:41:01 UTC 2021


On Thu, 6 May 2021 09:02:49 GMT, Volker Simonis <simonis 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
>
> test/hotspot/gtest/runtime/test_os.cpp line 766:
> 
>> 764:   const size_t lp = strlen(pattern);
>> 765:   const size_t ls = strlen(s);
>> 766:   if (ls < lp) {
> 
> Shouldn't this be `!=`?

I wanted to be able to give prefix pattern which do not cover the whole string.

> test/hotspot/gtest/runtime/test_os.cpp line 800:
> 
>> 798:   tty->print_cr("%s", result);
>> 799:   EXPECT_EQ(result, buffer);
>> 800:   EXPECT_TRUE(very_simple_string_matcher(pattern, result));
> 
> Do you intentionally repeat this same test for a second time? Does it provide any benefit?

Oops, no, this is an oversight. I'll remove the second test, thanks for catching this.

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

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


More information about the hotspot-runtime-dev mailing list