On Wed, 5 May 2021 20:26:13 GMT, Alex Menkov <[email protected]> wrote:

> Class loading can happen on different threads, but HotSwap agent is not ready 
> to this - classCount variable is used without any synchronization.
> The fix adds synchronization for ClassFileLoadHook.

Also, generic comment. There are other counters which might require 
synchronization, like CompiledMethodLoadEventsCount. Doesn't it makes sense to 
fix them also or file a new bug?

test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/hotswap/HotSwap.cpp line 71:

> 69: static int classCount = 0;
> 70: /* lock to access classCount */
> 71: static jrawMonitorID classLoadLock = NULL;

I think it would simpler to use an atomic counter rather than monitors for this 
fix.

test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/hotswap/HotSwap.cpp line 110:

> 108:         }
> 109:         // use while instead of if to exit the block on error
> 110:         while (classCount < max_classes) {

Could you please explain why this while is executed only once. It is not 
obvious.

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

Changes requested by lmesnik (Committer).

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

Reply via email to