RFR: 8060130: Simplify the synchronization of defining and getting java.lang.Package
mandy.chung at oracle.com
Wed Oct 15 00:22:52 UTC 2014
On 10/13/2014 5:50 AM, David M. Lloyd wrote:
> On 10/10/2014 07:31 PM, Mandy Chung wrote:
>> On 10/10/2014 8:10 AM, Claes Redestad wrote:
>>> Hi all,
>>> please review this patch which attempts to clean up synchronization
>>> and improve scalability when
>>> defining and getting java.lang.Package objects.
>> I agree with David that getting Package objects are not performance
>> critical. On the other hand, the code defining/getting Packages is
>> old and deserves some cleanup especially the synchronization part.
> I have a little more information on this subject. We've a possible
> (and somewhat likely) deadlock which occurs because one thread can
> attempt to define a system class while holding the
> java.lang.Package#pkgs lock, while another thread can attempt to get a
> package while defining a system class (while holding the class loader
> lock). I do not recall whether parallel class loading alleviates this
> issue. We solved the problem by loading Packages.getPackages() in
> early (single-threaded) bootstrap.
Do you recall what JDK version you observed this possible deadlock? I
wonder if the fix for 7001933  in JDK 7 and 6u25 resolved the
deadlock problem you ran into.
> So from my perspective, just getting rid of the synchronization on
> that field alone makes this change worthwhile.
Yes that's what I think too.
More information about the core-libs-dev