[PATCH] 8247402: Rewrite the implementation requirements for Map::compute()
林自均
johnlinp at gmail.com
Sat Jun 20 01:00:37 UTC 2020
Hi Martin,
Any update on this? Thanks!
Best,
John Lin
林自均 <johnlinp at gmail.com> 於 2020年6月13日 週六 上午11:08寫道:
>
> Hi Martin,
>
> I see your point. Thank you for demostrating this for me.
>
> Here's my updated patch:
>
> # HG changeset patch
> # User John Lin <johnlinp at gmail.com>
> # Date 1591923561 -28800
> # Fri Jun 12 08:59:21 2020 +0800
> # Node ID e01d9d020506a88d3d585bd3264594a26450c659
> # 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);
> + * if (newValue != null) {
> + * map.put(key, newValue);
> * } else {
> - * if (newValue != null)
> - * map.put(key, newValue);
> - * else
> - * return null;
> + * map.remove(key);
> * }
> + * return newValue;
> * }</pre>
> *
> * <p>The default implementation makes no guarantees about detecting if the
>
> By the way, I saw everyone in this mailing list is using webrev.
> However, the tutorial https://openjdk.java.net/guide/codeReview.html
> says that only the users with push access to the OpenJDK Mercurial
> server can use webrev. Can I apply for push access to the OpenJDK
> Mercurial server too?
>
> Best,
> John Lin
>
> Martin Buchholz <martinrb at google.com> 於 2020年6月13日 週六 上午12:36寫道:
> >
> > If I rub that program, I get:
> >
> > HashMap false
> > HashMap1 false
> > HashMap2 true
> >
> > which suggests that HashMap2's implementation is wrong.
More information about the core-libs-dev
mailing list