RFR: JDK-8238648 Rename and simplify Utils.WeakSoftHashMap

Jonathan Gibbons jonathan.gibbons at oracle.com
Sat Feb 8 00:17:23 UTC 2020


Thank you.

-- Jon


On 02/07/2020 08:25 AM, Hannes Wallnöfer wrote:
> Nice cleanup. Looks good!
>
> Hannes
>
>
>> Am 07.02.2020 um 03:31 schrieb Jonathan Gibbons <jonathan.gibbons at oracle.com>:
>>
>> Please review a 1-file cleanup to rename and simplify Utils.WeakSoftHashMap.
>>
>> Utils.WeakSoftHashMap sounds like a general collection but is specifically an impl of Map<Element,CommentHelper>.
>>
>> Furthermore, although it declares that it implements Map<Element,CommentHelper>, it is always used explicitly via its own class name, and never as a Map. This means that we can determine the methods that are required (get, put, remove, computeIfAbsent) and delete the others.
>>
>> Finally, it is "just" a memory sensitive cache for CommentHelper objects, and so a better name for the class is just CommentHelperCache.
>>
>> That all being said, there is one small but notable change. Previously, the code used a WeakHashMap<Element, ...>, so that the cache would not hold on unnecessarily to the keys. But the reality is that javac never drops references to elements in the javac symbol tables, and javadoc has many other Map<Element, ?> and so there is really no point in this cache using a WeakHashMap. It is therefore changes to a plain simple HashMap.
>>
>> -- Jon
>>
>> JBS: https://bugs.openjdk.java.net/browse/JDK-8238648
>> Webrev: http://cr.openjdk.java.net/~jjg/8238648/webrev/index.html
>>



More information about the javadoc-dev mailing list