Details
-
Bug
-
Resolution: Fixed
-
P2
-
8, 8-repo-lambda
-
b115
-
Verified
Description
Specification
http://download.java.net/jdk8/docs/api/java/util/Map.html#merge%28K,%20V,%20java.util.function.BiFunction%29
states:
"If the specified key is not already associated with a value or is associated with null, associates it with the given value."
The implementation behavior of JDK8-LAMBDA (probably starting from b106) contradicts the spec in case if the given key is associated with "null"
Consider the following code sample:
-------------------------------
final HashMap map = new HashMap();
map.put("a", null);
System.out.println("result = " + map.merge("a", "new", (v1, v2) -> "merged"));
-------------------------------
JDK8b106-lambda:
result = merged
on JDK8b106:
result = new
The following JCK tests fail due to this:
api/java_util/Collections/checked/CheckedMap8Tests.html#CheckedMap8Tests[merge_nullKeyValue_noNPE]
api/java_util/Collections/checked/CheckedMap8Tests.html#CheckedMap8Tests[merge_nullKey_noNPE]
api/java_util/Collections/synchronizd/SynchronizedMap8Tests.html#SynchronizedMap8Tests[merge_nullKeyValue_noNPE]
api/java_util/Collections/synchronizd/SynchronizedMap8Tests.html#SynchronizedMap8Tests[merge_nullKey_noNPE]
api/java_util/HashMap/Map8Tests.html#Map8Tests[merge_nullKeyValue_noNPE]
api/java_util/HashMap/Map8Tests.html#Map8Tests[merge_nullKey_noNPE]
api/java_util/LinkedHashMap/Map8Tests.html#Map8Tests[merge_nullKeyValue_noNPE]
api/java_util/LinkedHashMap/Map8Tests.html#Map8Tests[merge_nullKey_noNPE]
api/java_util/Collections/checked/CheckedMap8Tests.html#CheckedMap8Tests[merge_presentKey_mappedToNull_newValue]
api/java_util/Collections/synchronizd/SynchronizedMap8Tests.html#SynchronizedMap8Tests[merge_presentKey_mappedToNull_newValue]
api/java_util/HashMap/Map8Tests.html#Map8Tests[merge_presentKey_mappedToNull_newValue]
api/java_util/LinkedHashMap/Map8Tests.html#Map8Tests[merge_presentKey_mappedToNull_newValue]
http://download.java.net/jdk8/docs/api/java/util/Map.html#merge%28K,%20V,%20java.util.function.BiFunction%29
states:
"If the specified key is not already associated with a value or is associated with null, associates it with the given value."
The implementation behavior of JDK8-LAMBDA (probably starting from b106) contradicts the spec in case if the given key is associated with "null"
Consider the following code sample:
-------------------------------
final HashMap map = new HashMap();
map.put("a", null);
System.out.println("result = " + map.merge("a", "new", (v1, v2) -> "merged"));
-------------------------------
JDK8b106-lambda:
result = merged
on JDK8b106:
result = new
The following JCK tests fail due to this:
api/java_util/Collections/checked/CheckedMap8Tests.html#CheckedMap8Tests[merge_nullKeyValue_noNPE]
api/java_util/Collections/checked/CheckedMap8Tests.html#CheckedMap8Tests[merge_nullKey_noNPE]
api/java_util/Collections/synchronizd/SynchronizedMap8Tests.html#SynchronizedMap8Tests[merge_nullKeyValue_noNPE]
api/java_util/Collections/synchronizd/SynchronizedMap8Tests.html#SynchronizedMap8Tests[merge_nullKey_noNPE]
api/java_util/HashMap/Map8Tests.html#Map8Tests[merge_nullKeyValue_noNPE]
api/java_util/HashMap/Map8Tests.html#Map8Tests[merge_nullKey_noNPE]
api/java_util/LinkedHashMap/Map8Tests.html#Map8Tests[merge_nullKeyValue_noNPE]
api/java_util/LinkedHashMap/Map8Tests.html#Map8Tests[merge_nullKey_noNPE]
api/java_util/Collections/checked/CheckedMap8Tests.html#CheckedMap8Tests[merge_presentKey_mappedToNull_newValue]
api/java_util/Collections/synchronizd/SynchronizedMap8Tests.html#SynchronizedMap8Tests[merge_presentKey_mappedToNull_newValue]
api/java_util/HashMap/Map8Tests.html#Map8Tests[merge_presentKey_mappedToNull_newValue]
api/java_util/LinkedHashMap/Map8Tests.html#Map8Tests[merge_presentKey_mappedToNull_newValue]
Attachments
Issue Links
- relates to
-
JDK-8027125 Many Map impls missing @throws declarations in javadoc
- Open