Please review JDK-8059321
    Aleksey Shipilev 
    aleksey.shipilev at oracle.com
       
    Mon Sep 29 18:55:55 UTC 2014
    
    
  
On 09/29/2014 10:45 PM, Marcus Lagergren wrote:
> OK. New webrev here
> http://cr.openjdk.java.net/~lagergren/8059321.2/webrev/
...
> Let me know if this is semantically sound. From reading the OpenJDK
> code, I think it is.
I would think it should be reversed, in case adapter wants to do
multiple operations on the backing map:
     private static final Set<String> VALID_CACHE_SET =
          Collections.synchronizedSet(
                Collections.newSetFromMap(
                             new WeakHashMap<String, Boolean>()));
Also, the beauty of Set shines here:
  public static void validate(final String pattern, final String flags)
       throws ParserException {
    final Set<String> cache = VALID_CACHE_SET;
    if (VALID_CACHE_SET.add(pattern + flags)) {
      instance.compile(pattern, flags);
    }
  }
-Aleksey.
    
    
More information about the nashorn-dev
mailing list