RFR: 8279917: Refactor subclassAudits in Thread to use ClassValue [v2]
Roman Kennke
rkennke at openjdk.java.net
Thu Jan 13 12:27:31 UTC 2022
On Thu, 13 Jan 2022 10:02:04 GMT, Andrey Turbanov <duke at openjdk.java.net> wrote:
>> Roman Kennke has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Remove obsolete comment
>
> src/java.base/share/classes/java/lang/Thread.java line 1671:
>
>> 1669: /** cache of subclass security audit results */
>> 1670: /* Replace with ConcurrentReferenceHashMap when/if it appears in a future
>> 1671: * release */
>
> Is it still desirable to use `ConcurrentReferenceHashMap` as suggested in comment? Or ClassValue is better choice?
Hmm, no. The use of Reference here is to avoid strong binding to the Class key. However, we have seen weird interferences in ObjectStreamClass (see JDK-8277072) between this mechanism and class-unloading which prevents unloading the class sometimes (or at least, absent memory pressure that would trigger the GC to reclaim soft references). This code here in Thread.java is probably not affected by this problem, but ClassValue is still the cleaner way to establish a mapping between a Class and some value. I have removed the comment.
-------------
PR: https://git.openjdk.java.net/jdk/pull/7054
More information about the core-libs-dev
mailing list