-
Bug
-
Resolution: Fixed
-
P3
-
5.0, 6, 6u23
-
b140
-
generic, x86
-
generic, windows_xp
-
Verified
Some Map implementations have an entrySet() method returning a set
with an iterator method returning an iterator which returns the
same (as in object identity) Map.Entry on each call to next().
This works well in the usual case where each entry is discarded
(effectively becomes garbage) before next() is called.
However, if entries are saved, perhaps to build up other collections or
arrays, they will need to be defensively copied by the caller before next()
is called. This is an optimization to prevent garbage being generated on each
call to next(). However, the cost of creating many small short-lived objects is much
lower than it used to be in most implementations, and is likely to get even lower as VM
optimizations such as escape analysis and stack allocation are implemented.
Therefore such error-prone optimizations such as this one should be removed at
some point.
with an iterator method returning an iterator which returns the
same (as in object identity) Map.Entry on each call to next().
This works well in the usual case where each entry is discarded
(effectively becomes garbage) before next() is called.
However, if entries are saved, perhaps to build up other collections or
arrays, they will need to be defensively copied by the caller before next()
is called. This is an optimization to prevent garbage being generated on each
call to next(). However, the cost of creating many small short-lived objects is much
lower than it used to be in most implementations, and is likely to get even lower as VM
optimizations such as escape analysis and stack allocation are implemented.
Therefore such error-prone optimizations such as this one should be removed at
some point.
- duplicates
-
JDK-7014779 Iterator for EnumMap.entrySet() returns results which cannot be used to build a Set<Map.Entry>
- Closed
-
JDK-7020923 Unexpected behavior of EnumMap.entrySet()
- Closed
- relates to
-
JDK-6197726 (coll) IdentityHashMap.entrySet().toArray(T[] a) is incorrectly implemented
- Closed
-
JDK-6232484 (coll) ArrayList made from IdentityHashMap.entrySet() fails to create properly
- Closed
-
JDK-7035160 (reflect) test/java/lang/reflect/Generics/Probe.java failing
- Closed
-
JDK-7123229 (coll) EnumMap.containsValue(null) returns true
- Closed
(1 relates to)