RFR : 8016446 : (m) Add override forEach/replaceAll to HashMap, Hashtable, IdentityHashMap, WeakHashMap, TreeMap
Doug Lea
dl at cs.oswego.edu
Wed Jun 19 11:23:48 UTC 2013
On 06/19/13 06:48, Peter Levart wrote:
> On 06/19/2013 11:45 AM, Paul Sandoz wrote:
>> >>Per a suggestion from Remi I updated the ConcurrentMap.replaceAll default to
>> use forEach. This trades off the entrySet iterator overhead for creation of a
>> capturing BiConsumer lambda.
>
> But only in ConcurrentMap implementations that do override forEach (and don't
> override replaceAll).
Right. I think the safest choice was the original one.
On 06/19/2013 11:45 AM, Paul Sandoz wrote:
>
> This is another little oddity in Map.forEach:
>
> try {
> k = entry.getKey();
> v = entry.getValue();
> } catch(IllegalStateException ise) {
> throw new ConcurrentModificationException(ise);
> }
>
> I would presume the entries from CconcurrentMap.entrySet would not throw ISEs
There's nothing saying they can't, so this seems harmless enough.
Considering that there are only a few ConcurrentMap implementations
in existence outside of JDK, and that anyone going through the
substantial effort to create one is sure to override defaults
the next chance they get on or before JDK8 release, it seems fine to
aim for the safest correct choices for defaults.
-Doug
More information about the core-libs-dev
mailing list