RFR: JDK-8314752: Use google test string comparison macros

Kim Barrett kbarrett at openjdk.org
Tue Aug 22 19:14:17 UTC 2023


On Sun, 20 Aug 2023 10:09:49 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

> Small improvement to use google test's string comparison macros instead of raw C-functions.
> 
> This makes the code more readable and provides us with automatic error output in case of string mismatches (so we don't have to print the values via "<<").

Looks good.

test/hotspot/gtest/runtime/test_classPrinter.cpp line 59:

> 57:   ASSERT_THAT(o1, HasSubstr("method wait : (J)V")) << "must find java/lang/Object::wait(long)";
> 58:   ASSERT_THAT(o1, HasSubstr("method wait : ()V")) << "must find java/lang/Object::wait()";
> 59:   ASSERT_THAT(o1, Not(HasSubstr("method finalize : ()V"))) << "must not find java/lang/Object::finalize";

It required some research for me to understand how `Not` is working here and below.  It's relying on ADL.
That used to be at best unreliable or not work at all in some common compilers, but I think that's mostly
fixed now.  Since we don't use namespaces in HotSpot, ADL is not encountered much in our code.  I'm
okay with this, but others might be surprised too.

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

Marked as reviewed by kbarrett (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/15355#pullrequestreview-1590119587
PR Review Comment: https://git.openjdk.org/jdk/pull/15355#discussion_r1302062858


More information about the hotspot-dev mailing list