On Thu, 17 Feb 2022 13:49:52 GMT, Zhengyu Gu <z...@openjdk.org> wrote:

> I believe checking `bagSize() == 0` is an optimization. I think just taking 
> `handlerLock` lock before calling `classTrack_reset()` ensures no race can 
> happen and seems harmless.

Yes, it would be an optimization, and one I'm now seeing is not really needed 
since processUnloads() is not called as frequently as I thought (only called 
after a GC completes).

The grabbing of the handlerLock is questionable. Kim also called it out in 
[JDK-8256811](https://bugs.openjdk.java.net/browse/JDK-8256811):

``` I think this can be fixed by removing the conditionalization of the call to 
classTrack_processUnloads, and just do it unconditionally. There is a (somewhat 
confusing) comment saying that the conditionalization is there to avoid taking 
the handler lock when that isn't needed. But it's not clear why that lock is 
being taken on that code path at all, as classTrack_processUnloads contains 
it's own internal locking. ```

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

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

Reply via email to