Extra points would be to substitute the resulting snippet for the actual
implementation to see if it compiles and satisfies the tests. For example, like
this:
default boolean replace(K key, V oldValue, V newValue) {
Map<K, V> map = this; // synthetic line
if (map.containsKey(key) && Objects.equals(map.get(key), oldValue)) {
map.put(key, newValue);
return true;
} else
return false;
}
One of these days snippets/examples may become verifiable. Until then we should
check them in doc comments that are most read, occasionally, in a manual
fashion.
Otherwise, looks good.
-Pavel
> On 5 Jun 2020, at 16:20, Conor Cleary <[email protected]> wrote:
>
> Hi,
>
> Could someone please take a look at my webrev for JDK-8243655 'Map.replace
> javadoc code snippet typo'?
>
> This fix addresses a typo in the javadoc for Map.replace(K, V, V) in the
> default implementation code. The parameter 'value' in the conditional block
> is changed to 'oldValue' to reflect the originally passed variable name.
>
>
> bug: https://bugs.openjdk.java.net/browse/JDK-8243655
> webrev: http://cr.openjdk.java.net/~jboes/ccleary/webrevs/8243655/webrev.00/
>
>
> Regards,
> Conor
>