On Tue, 13 Oct 2020 16:17:49 GMT, Stuart Marks <[email protected]> wrote:
>> Perhaps I should clarify my previous comment. When I said "implementation" >> what I meant was that pseudo-code inside the >> `@implSpec` tag, not the actual body of `default V compute(K key, >> BiFunction<? super K, ? super V, ? extends V> >> remappingFunction)`. > > This change is to a normative portion of the specification, and as such will > require a CSR. Hi @pavelrappo & @stuart-marks, Thank you for the review. When I first proposed this patch in the mailing list, the patch looked like this: # HG changeset patch # User John Lin <[email protected]> # Date 1591923561 -28800 # Fri Jun 12 08:59:21 2020 +0800 # Node ID 03c9b5c9e632a0d6e33a1f13c98bb3b31b1bf659 # Parent 49a68abdb0ba68351db0f140ddac793b1c391bd5 8247402: Rewrite the implementation requirements for Map::compute() diff --git a/src/java.base/share/classes/java/util/Map.java b/src/java.base/share/classes/java/util/Map.java --- a/src/java.base/share/classes/java/util/Map.java +++ b/src/java.base/share/classes/java/util/Map.java @@ -1113,17 +1113,12 @@ public interface Map<K, V> { * <pre> {@code * V oldValue = map.get(key); * V newValue = remappingFunction.apply(key, oldValue); - * if (oldValue != null) { - * if (newValue != null) - * map.put(key, newValue); - * else - * map.remove(key); - * } else { - * if (newValue != null) - * map.put(key, newValue); - * else - * return null; + * if (newValue != null) { + * map.put(key, newValue); + * } else if (oldValue != null) { + * map.remove(key); * } + * return newValue; * }</pre> * * <p>The default implementation makes no guarantees about detecting if the which didn't change the pseudo-code implementation. However, Martin Buchholz reviewed my patch and suggested me to modify it to match the real implementation in HashMap: https://www.mail-archive.com/[email protected]/msg66197.html https://www.mail-archive.com/[email protected]/msg66199.html https://www.mail-archive.com/[email protected]/msg66210.html Therefore, I modified my patch and submitted it in the original mailing list and in this PR. I don't think creating a CSR is in the scope of JDK-8247402. I'll create another PR with my original patch. Thanks. ------------- PR: https://git.openjdk.java.net/jdk/pull/451
