RFR: JDK-8310913 Move ReferencedKeyMap to jdk.internal so it may be shared [v4]

Mandy Chung mchung at openjdk.org
Thu Jul 6 16:37:02 UTC 2023


On Thu, 6 Jul 2023 12:20:15 GMT, Jim Laskey <jlaskey at openjdk.org> wrote:

>> java.lang.runtime.ReferencedKeyMap was introduced to provide a concurrent caching scheme for Carrier objects. The technique used is generally useful for a variety of caching schemes and is being moved to be shared in other parts of the jdk. The MethodType interning case is one example.
>
> Jim Laskey has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains ten commits:
> 
>  - Merge branch 'master' into 8310913
>  - Update to use VirtualThread friendly stale queue.
>  - Remove warning tied to String Templates
>  - unneeded SuppressWarning
>  - Wrong cast
>  - Move jdk.internal.referencedkey to jdk.internal.util
>  - Merge branch 'master' into 8310913
>  - Update MethodType to use ReferencedKeySet
>  - Initial commit for ReferencedKeyMap and ReferencedKeySet

src/java.base/share/classes/jdk/internal/util/ReferencedKeyMap.java line 111:

> 109:         this.isSoft = isSoft;
> 110:         this.map = map;
> 111:         this.stale = SharedSecrets.getJavaLangRefAccess().newNativeReferenceQueue();

I don't think you want all `ReferencedKeyMap` instances use native reference queue which may cause the virtual thread to pin on the carrier thread if it synchronizes the monitor lock.

Perhaps add a new factory method that takes a `ReferenceQueue` and `MethodType` will create it with `NativeReferenceQueue`.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14684#discussion_r1254677202


More information about the core-libs-dev mailing list