RFR: 8004518 & 8010122 : Default methods on Map
mike.duigou at oracle.com
Thu Apr 11 13:03:23 PDT 2013
Another revision incorporating primarily documentation feedback.
I've also included the java.util.Collections overrides for the default methods. All of these are performance enhancements--the semantics were already correct because the defaults use only public methods.
This is likely, modulo formatting of the source examples, the version that will be pushed to TL on Friday unless somebody squawks.
Moving the current compute, computeIfPresent, computeIfAbsent and merge defaults to ConcurrentMap and replacing the current Map defaults with versions that throw ConcurrentModificationException will likely be resolved in a future issue if the EG determines it to be important.
On Apr 10 2013, at 22:42 , Mike Duigou wrote:
> I've posted an updated webrev with the review comments I have received.
> One important point to consider:
> - The current implementations of compute, computeIfPresent, computeIfAbsent, merge are implemented so that they can work correctly for ConcurrentMap instances. For non-concurrent implementations it might be better to fail and throw ConcurrentModification exception whenever concurrent modification is detected. For regular Map implementations the retry behaviour will only serve to mask errors.
> On Apr 8 2013, at 11:07 , Mike Duigou wrote:
>> Hello all;
>> This is a combined review for the new default methods on the java.util.Map interface being added for the JSR-335 lambda libraries. The reviews are being combined because they share a common unit test.
>> 8004518: Add in-place operations to Map
>> 8010122: Add atomic operations to Map
>> putIfAbsent() *
>> remove(K, V)
>> replace(K, V)
>> replace(K, V, V)
>> compute() *
>> merge() *
>> computeIfAbsent() *
>> computeIfPresent() *
>> The * operations treat null values as being absent. (ie. the same as there being no mapping for the specified key).
>> The default implementations provided in Map are overridden in HashMap for performance purposes, in Hashtable for atomicity and performance purposes and in Collections for atomicity.
More information about the lambda-dev