On Wed, 5 May 2021 21:01:11 GMT, Leonid Mesnik <lmes...@openjdk.org> 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.
>
> 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.

I tried to explain it in the comment :)
it should be "if (classCount < max_classes)",
but inside the if we have return statements and we need to do cleanup (exit 
monitor).
So I used well-known pattern with 1-pass cycle (note that "return"s are 
replaced with "break"s)

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

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

Reply via email to