RFR: 8060130: Simplify the synchronization of defining and getting java.lang.Package

Mandy Chung 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 [1] in JDK 7 and 6u25 resolved the 
deadlock problem you ran into.

[1] http://hg.openjdk.java.net/jdk9/dev/jdk/rev/4a7da412db38

> 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.

Mandy



More information about the core-libs-dev mailing list