RFR (XS) 8145539: (coll) AbstractMap.keySet and .values should not be volatile

Aleksey Shipilev aleksey.shipilev at oracle.com
Thu Dec 17 15:54:05 UTC 2015


On 12/17/2015 06:07 PM, Doug Lea wrote:
> On 12/16/2015 05:53 PM, Aleksey Shipilev wrote:
>> Since the dawn of OpenJDK, AbstractMap.keySet and .value were defined as
>> package-private volatile fields. Their only use is to cache keySet and
>> valueSet implementations from java.util collections.
> 
> I think these were declared volatile to be more clearly JMM compliant.
> They are definitely OK without it, but you should probably add some
> rationale in documentation, mentioning that all java.util.Map view class
> implementations using these fields have no non-final fields (or any
> fields at all except for outer-this).

Good idea, did so:
 http://cr.openjdk.java.net/~shade/8145539/webrev.04/

(There is also an @implSpec on keySet() and values() that say no
synchronization is performed)

Thanks,
-Aleksey




More information about the core-libs-dev mailing list