RFR: 8292375: Convert ProtectionDomainCacheTable to ResourceHashtable [v7]

David Holmes dholmes at openjdk.org
Thu Sep 1 06:55:03 UTC 2022


On Thu, 1 Sep 2022 06:42:06 GMT, Ioi Lam <iklam at openjdk.org> wrote:

>> src/hotspot/share/classfile/protectionDomainCache.hpp line 33:
>> 
>>> 31: 
>>> 32: // The ProtectionDomainCacheTable maps all java.security.ProtectionDomain objects that are
>>> 33: // registered by DictionaryEntry::add_protection_domain() to a unique WeakHandle.
>> 
>> Now that I understand what this table does, this comment is confusing to me. The table maps each PD to itself (using the WeakHandle as the actual key and value) as a means to track which PDs have been seen/registered. I would describe it thus:
>> 
>> // The ProtectionDomainCacheTable records all of the java.security.ProtectionDomain instances that have
>> // been registered by DictionaryEntry::add_protection_domain(). We use a hashtable to
>> map each  PD 
>> // instance to itself (using WeakHandles) to allow for fast lookup.
>
> “Mapping to itself” is how this table works internally. I am not sure if this information is useful here. But the purpose of this table is really to keep track of all PDs that have been registered and not yet garbage collected.

"mapping to itself" is more useful than "mapping ... to a unique Weakhandle" - which is even more of an internal implementation detail. I found the use of this table very hard to discern based on the internal use of the hashtable, as there is no real mapping operation - we simply track if a PD has been seen or not. The use of the hashtable is purely for lookup convenience - we could instead have a linked-list of PD's that we traverse for lookup.
So perhaps we drop my second sentence above, and move it to where the hashtable itself is declared?

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

PR: https://git.openjdk.org/jdk/pull/10043


More information about the serviceability-dev mailing list