-
Bug
-
Resolution: Not an Issue
-
P2
-
None
-
8
-
b97
Consider the following code:
--------------
final HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("a", "b");
final Set<Map.Entry<String, String>> set = Collections.checkedMap(hashMap, String.class, String.class).entrySet();
// final Set<Map.Entry<String, String>> set = Collections.unmodifiableMap(hashMap).entrySet();
Map.Entry<String, String> e1 = set.iterator().next();
Map.Entry<String, String> e2 = set.stream().findFirst().get();
System.err.println("same instances? " + (e1 == e2));
-----------------
The output will be:
same instances? false
The following JCK tests fail due to this issue:
api/java_util/Collections/checked/index.html#CheckedMapEntrySetStream
api/java_util/Collections/checked/index.html#CheckedMapEntrySetParallelStream
api/java_util/Collections/checked/index.html#CheckedSortedMapEntrySetParallelStream
api/java_util/Collections/checked/index.html#CheckedSortedMapEntrySetStream
api/java_util/Collections/unmodifiable/index.html#UnmodifiableMapEntrySetStream
api/java_util/Collections/unmodifiable/index.html#UnmodifiableMapEntrySetParallelStream
api/java_util/Collections/unmodifiable/index.html#UnmodifiableSortedMapEntrySetParallelStream
api/java_util/Collections/unmodifiable/index.html#UnmodifiableSortedMapEntrySetStream
--------------
final HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("a", "b");
final Set<Map.Entry<String, String>> set = Collections.checkedMap(hashMap, String.class, String.class).entrySet();
// final Set<Map.Entry<String, String>> set = Collections.unmodifiableMap(hashMap).entrySet();
Map.Entry<String, String> e1 = set.iterator().next();
Map.Entry<String, String> e2 = set.stream().findFirst().get();
System.err.println("same instances? " + (e1 == e2));
-----------------
The output will be:
same instances? false
The following JCK tests fail due to this issue:
api/java_util/Collections/checked/index.html#CheckedMapEntrySetStream
api/java_util/Collections/checked/index.html#CheckedMapEntrySetParallelStream
api/java_util/Collections/checked/index.html#CheckedSortedMapEntrySetParallelStream
api/java_util/Collections/checked/index.html#CheckedSortedMapEntrySetStream
api/java_util/Collections/unmodifiable/index.html#UnmodifiableMapEntrySetStream
api/java_util/Collections/unmodifiable/index.html#UnmodifiableMapEntrySetParallelStream
api/java_util/Collections/unmodifiable/index.html#UnmodifiableSortedMapEntrySetParallelStream
api/java_util/Collections/unmodifiable/index.html#UnmodifiableSortedMapEntrySetStream
- relates to
-
JDK-8017447 Unmodifiable map entry becomes modifiable if taken from a stream of map entries
-
- Closed
-