[lworld] Integrated: 8286824: [lworld] WeakHashMap for value classes
Roger Riggs
rriggs at openjdk.org
Wed Nov 30 22:27:07 UTC 2022
On Thu, 30 Jun 2022 14:03:31 GMT, Roger Riggs <rriggs at openjdk.org> wrote:
> WeakHashMap uses WeakReference for keys, allowing it to retain only keys and values that are strongly referenced elsewhere.
>
> The behavior of WeakReference (or any Reference class) is not defined for value objects.
>
> Four (4) behaviors are proposed for WeakHashMap to give the developer a choice:
> - SOFT - Keys that are value objects are retained until memory pressure clears soft references; then the keys that are value objects are removed automatically
> - STRONG - Keys are value objects are retained until they are explicitly removed
> - THROW - Keys that are value objects can not be put into the map; UnsupportedOperationException is thrown
> - DISCARD - Keys that are value objects are silently discarded; as if they were removed immediately without being visible
>
> The default is SOFT - key/values are removed when there is memory pressure.
> Entries will be removed automatically at some point, though less deterministically than with WeakReferences.
This pull request has now been integrated.
Changeset: a4c6473b
Author: Roger Riggs <rriggs at openjdk.org>
URL: https://git.openjdk.org/valhalla/commit/a4c6473bf48541170792305f97456b24fdb49528
Stats: 466 lines in 3 files changed: 460 ins; 1 del; 5 mod
8286824: [lworld] WeakHashMap for value classes
-------------
PR: https://git.openjdk.org/valhalla/pull/718
More information about the valhalla-dev
mailing list