Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions src/java.base/share/classes/java/util/Map.java
Original file line number Diff line number Diff line change
Expand Up @@ -1174,8 +1174,8 @@ default boolean replace(K key, V oldValue, V newValue) {
* (<a href="{@docRoot}/java.base/java/util/Collection.html#optional-restrictions">optional</a>)
* @since 1.8
*/
default @PolyNull V computeIfPresent(K key,
BiFunction<? super K, ? super V, ? extends @PolyNull V> remappingFunction) {
default @Nullable V computeIfPresent(K key,
BiFunction<? super K, ? super V, ? extends @Nullable V> remappingFunction) {
Objects.requireNonNull(remappingFunction);
V oldValue;
if ((oldValue = get(key)) != null) {
Expand Down Expand Up @@ -1260,8 +1260,8 @@ default boolean replace(K key, V oldValue, V newValue) {
* (<a href="{@docRoot}/java.base/java/util/Collection.html#optional-restrictions">optional</a>)
* @since 1.8
*/
default @PolyNull V compute(K key,
BiFunction<? super K, ? super @Nullable V, ? extends @PolyNull V> remappingFunction) {
default @Nullable V compute(K key,
BiFunction<? super K, ? super @Nullable V, ? extends @Nullable V> remappingFunction) {
Objects.requireNonNull(remappingFunction);
V oldValue = get(key);

Expand Down Expand Up @@ -1358,12 +1358,8 @@ default boolean replace(K key, V oldValue, V newValue) {
* null
* @since 1.8
*/
@CFComment({
"It would be more flexible to make the return type of remappingFunction be `@Nullable V`. A",
"remappingFunction that returns null is is probably rare, and these annotations accommodate",
"the majority of uses that don't return null."})
default @PolyNull V merge(K key, @NonNull V value,
BiFunction<? super V, ? super V, ? extends @PolyNull V> remappingFunction) {
default @Nullable V merge(K key, @NonNull V value,
BiFunction<? super V, ? super V, ? extends @Nullable V> remappingFunction) {
Objects.requireNonNull(remappingFunction);
Objects.requireNonNull(value);
V oldValue = get(key);
Expand Down
Loading