Hi Ambarish,
Why not simply initialize yieldMethodID separately? For example in
Java_sun_awt_X11_XToolkit_initIDs.
--Semyon
On 06.07.2016 14:23, Ambarish Rapte wrote:
Hi,
Please review the fix for JDK9,
Bug: https://bugs.openjdk.java.net/browse/JDK-8146230
Webrev:
http://cr.openjdk.java.net/~arapte/8146230/webrev.00/
<http://cr.openjdk.java.net/%7Earapte/8146230/webrev.00/>
Issue:
1.Null pointer exception in JNI
Cause:
The code block was not multi thread safe.
Issue occurs in multi threaded , multi processor environment.
Fix:
1.Changed the variable used for double checking, to use /yieldMethodID ./
2.Changed /yieldMethodID to volatile./
3.Added AWT_LOCK() over initialize block of code.
4.Removed unrequired err variable.
A drawback of Double Check Locking ( DCL ) is, if the resource
assignment is not an atomic operation, The DCL may fail.
But here in the code of concern, is an atomic operation. Hence DCL
should work fine.
Please check below reference link for more detailed discussion of DCL
with C++.
Verification:
1.Tested Event tests which pass without any regression of this change.
2.As this change only corrects existing logic, there should be no side
effects.
Reference:
C++ and the Perils of Double-Checked Locking:
http://www.aristeia.com/Papers/DDJ_Jul_Aug_2004_revised.pdf
Regards,
Ambarish