Skip to content
Open
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions src/java.base/share/classes/java/util/Collections.java
Original file line number Diff line number Diff line change
Expand Up @@ -1653,7 +1653,7 @@ public V replace(K key, V value) {

@Override
public @PolyNull V compute(K key,
BiFunction<? super K, ? super V, ? extends @PolyNull V> remappingFunction) {
BiFunction<? super K, ? super @Nullable V, ? extends @PolyNull V> remappingFunction) {
throw new UnsupportedOperationException();
}

Expand Down Expand Up @@ -2863,7 +2863,7 @@ public V replace(K key, V value) {
}
@Override
public @PolyNull V compute(K key,
BiFunction<? super K, ? super V, ? extends @PolyNull V> remappingFunction) {
BiFunction<? super K, ? super @Nullable V, ? extends @PolyNull V> remappingFunction) {
synchronized (mutex) {return m.compute(key, remappingFunction);}
}
@Override
Expand Down Expand Up @@ -3957,7 +3957,7 @@ public V replace(K key, V value) {

@Override
public @PolyNull V compute(K key,
BiFunction<? super K, ? super V, ? extends @PolyNull V> remappingFunction) {
BiFunction<? super K, ? super @Nullable V, ? extends @PolyNull V> remappingFunction) {
return m.compute(key, typeCheck(remappingFunction));
}

Expand Down Expand Up @@ -4971,7 +4971,7 @@ public V replace(K key, V value) {

@Override
public @PolyNull V compute(K key,
BiFunction<? super K, ? super V, ? extends @PolyNull V> remappingFunction) {
BiFunction<? super K, ? super @Nullable V, ? extends @PolyNull V> remappingFunction) {
throw new UnsupportedOperationException();
}

Expand Down Expand Up @@ -5322,7 +5322,7 @@ public V replace(K key, V value) {

@Override
public @PolyNull V compute(K key,
BiFunction<? super K, ? super V, ? extends @PolyNull V> remappingFunction) {
BiFunction<? super K, ? super @Nullable V, ? extends @PolyNull V> remappingFunction) {
throw new UnsupportedOperationException();
}

Expand Down
2 changes: 1 addition & 1 deletion src/java.base/share/classes/java/util/HashMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,7 @@ else if (t != null)
*/
@Override
public @PolyNull V compute(K key,
BiFunction<? super K, ? super V, ? extends @PolyNull V> remappingFunction) {
BiFunction<? super K, ? super @Nullable V, ? extends @PolyNull V> remappingFunction) {
if (remappingFunction == null)
throw new NullPointerException();
int hash = hash(key);
Expand Down
2 changes: 1 addition & 1 deletion src/java.base/share/classes/java/util/Hashtable.java
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,7 @@ public synchronized boolean replace(K key, V oldValue, V newValue) {
* remapping function modified this map
*/
@Override
public synchronized @PolyNull V compute(K key, BiFunction<? super K, ? super V, ? extends @PolyNull V> remappingFunction) {
public synchronized @PolyNull V compute(K key, BiFunction<? super K, ? super @Nullable V, ? extends @PolyNull V> remappingFunction) {
Objects.requireNonNull(remappingFunction);

Entry<?,?> tab[] = table;
Expand Down
2 changes: 1 addition & 1 deletion src/java.base/share/classes/java/util/TreeMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -1878,7 +1878,7 @@ public V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction
return m.computeIfAbsent(key, mappingFunction);
}

public V compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
public V compute(K key, BiFunction<? super K, ? super @Nullable V, ? extends V> remappingFunction) {
if (!inRange(key)) {
// Do not throw if remapping function returns null
// to preserve compatibility with default computeIfAbsent implementation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ default void replaceAll(BiFunction<? super K, ? super V, ? extends V> function)
*/
@Override
default @PolyNull V compute(K key,
BiFunction<? super K, ? super V, ? extends @PolyNull V> remappingFunction) {
BiFunction<? super K, ? super @Nullable V, ? extends @PolyNull V> remappingFunction) {
retry: for (;;) {
V oldValue = get(key);
// if putIfAbsent fails, opportunistically use its return value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public ForwardingMap(Map<K, V> delegate) {
@Override public V replace(K key, V value) { return delegate.replace(key, value); }
@Override public V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) { return delegate.computeIfAbsent(key, mappingFunction); }
@Override public V computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) { return delegate.computeIfPresent(key, remappingFunction); }
@Override public V compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) { return delegate.compute(key, remappingFunction); }
@Override public V compute(K key, BiFunction<? super K, ? super @Nullable V, ? extends V> remappingFunction) { return delegate.compute(key, remappingFunction); }
@Override public V merge(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction) { return delegate.merge(key, value, remappingFunction); }
}

Expand Down
Loading