-
Enhancement
-
Resolution: Fixed
-
P4
-
8u66, 9
-
b99
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8149292 | 8u101 | Aleksey Shipilev | P4 | Resolved | Fixed | b01 |
JDK-8146114 | 8u92 | Aleksey Shipilev | P4 | Resolved | Fixed | b03 |
JDK-8155437 | emb-8u101 | Aleksey Shipilev | P4 | Resolved | Fixed | b01 |
A DESCRIPTION OF THE REQUEST :
AbstractMap has two fields which are declared volatile:
public abstract class AbstractMap<K,V> implements Map<K,V> {
.....
/**
* Each of these fields are initialized to contain an instance of the
* appropriate view the first time this view is requested. The views are
* stateless, so there's no reason to create more than one of each.
*/
transient volatile Set<K> keySet;
transient volatile Collection<V> values;
....
}
This is unnecessary since there is nothing in the API requiring these fields to be volatile.
JUSTIFICATION :
Removing volatile will reduce the cost of creating instances extending AbstractMap, as well as invoking e.g. ::values() and ::keySet() on a HashMap. In the application I'm working in hundreds of thousands HashMaps are created each second.
AbstractMap has two fields which are declared volatile:
public abstract class AbstractMap<K,V> implements Map<K,V> {
.....
/**
* Each of these fields are initialized to contain an instance of the
* appropriate view the first time this view is requested. The views are
* stateless, so there's no reason to create more than one of each.
*/
transient volatile Set<K> keySet;
transient volatile Collection<V> values;
....
}
This is unnecessary since there is nothing in the API requiring these fields to be volatile.
JUSTIFICATION :
Removing volatile will reduce the cost of creating instances extending AbstractMap, as well as invoking e.g. ::values() and ::keySet() on a HashMap. In the application I'm working in hundreds of thousands HashMaps are created each second.
- backported by
-
JDK-8146114 (coll) AbstractMap.keySet and .values should not be volatile
-
- Resolved
-
-
JDK-8149292 (coll) AbstractMap.keySet and .values should not be volatile
-
- Resolved
-
-
JDK-8155437 (coll) AbstractMap.keySet and .values should not be volatile
-
- Resolved
-
- relates to
-
JDK-8035284 AbstractMap unnecessarily initializes two volatiles to null
-
- Resolved
-
-
JDK-8316493 Remove the caching fields in AbstractMap
-
- In Progress
-