On Thu, 26 Aug 2021 23:49:07 GMT, David Holmes <dhol...@openjdk.org> wrote:

>> Vladimir Ivanov has updated the pull request incrementally with one 
>> additional commit since the last revision:
>> 
>>   Improve comments
>
> src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java line 385:
> 
>> 383:         Class<?> defc = member.getDeclaringClass();
>> 384:         UNSAFE.ensureClassInitialized(defc); // initialization barrier; 
>> blocks unless called by the initializing thread
>> 385:         return !UNSAFE.shouldBeInitialized(defc); // keep the barrier 
>> if the initialization is still in progress
> 
> I think some more elaborate commentary about the possibility of this being 
> called while <clinit> of defc is already on the call stack, would be 
> worthwhile - the existing comments are a little too subtle IMO.
> 
> 
> UNSAFE.ensureClassInitialized(defc);
> // Once we get here either defc was fully initialized by another thread, or
> // defc was already being initialized by the current thread. In the latter 
> case
> // the barrier must remain. We can detect this simply by checking if 
> initialization
> // is still needed.
> return !UNSAFE.shouldBeInitialized(defc);

Thanks, David. I incorporated your suggestion in the latest version.

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

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

Reply via email to