RFR: 8290812: Add a test for ResourceHashtable [v3]

Coleen Phillimore coleenp at openjdk.org
Fri Jul 22 11:59:03 UTC 2022


On Fri, 22 Jul 2022 05:42:35 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

>> Coleen Phillimore has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Clarify the do_entry functions in two deleter classes.
>
> test/hotspot/gtest/utilities/test_resourceHash.cpp line 354:
> 
>> 352:     ASSERT_EQ(s->refcount(), s_orig_count + 3) << "refcount incremented";
>> 353:   }
>> 354:   ASSERT_EQ(s->refcount(), s_orig_count + 2) << "refcount not copied";
> 
> I may misunderstand things, but why do you test the same sequence twice? The first one above seems not to match your description since the value holds the Symbol secure during its lifetime.
> 
> If you wanted to test what the comment describes you would add a value that does nothing to the Symbol*. But I'm not sure that is even worth testing since it is clear what happens (if you put Symbol* as key and whatever as value, nobody will increase the refcount of Symbol*).

Yes, the first line (344) holds the value through the lifetime but I assert that at the end the refcount is where we started.
The second sequence tests the unlink function, which acts differently than remove. In remove, we have to do any refcounting cleanup for the key except destruction because remove doesn't have a callback.  In unlink, we have to do the cleanup in the callback.
I'm not sure what your suggested test would do, except underflow the refcount of the symbol, which I don't want to do because then it'd be a negative test.

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

PR: https://git.openjdk.org/jdk/pull/9603


More information about the hotspot-dev mailing list