Hi,

On 2018-02-07 13:55, Peter Levart wrote:

Would making CacheEntry extend jdk.internal.ref.SoftCleanable instead of SoftReference help here? You could remove the cleanStaleEntries method entirely and just remove the Map entry in SoftCleanable's performCleanup method.

possible, but that'd be a larger change than I'm comfortable with for now.

As Locale is initialized on bootstrap, a Cleaner-based impl. would mean starting an innocuous thread unconditionally, which would defeat the intent to optimize the minimal time to bootstrap the JVM. If we could tease things apart even further
so that a SoftCleanable and Cleaners are only set up when initializing any
non-constant Locale then I think we should contemplate this as a follow up.

Updated webrev:

http://cr.openjdk.java.net/~redestad/8196869/jdk.02/

- use map.remove(entry.getKey(), entry) instead of map.remove(entry.getKey()) - for most Locales, Locale$LocaleKey.exts is null, so using the BaseLocale as key   directly in Locale allows us to avoid loading Locale$LocaleKey except in exceptional
  circumstances.
- use map.replace to safely update the entry when putIfAbsent returns an object   but it points to a cleared value, so that (benign) races to create new Locale objects
  will canonicalize

/Claes

Reply via email to