--- old/src/java.base/share/classes/java/util/TreeMap.java 2020-05-03 07:52:12.412000000 +0000 +++ new/src/java.base/share/classes/java/util/TreeMap.java 2020-05-03 07:52:12.032000000 +0000 @@ -1790,6 +1790,38 @@ return m.put(key, value); } + public V putIfAbsent(K key, V value) { + if (!inRange(key)) + throw new IllegalArgumentException("key out of range"); + return m.putIfAbsent(key, value); + } + + public V merge(K key, V value, BiFunction remappingFunction) { + if (!inRange(key)) + throw new IllegalArgumentException("key out of range"); + return m.merge(key, value, remappingFunction); + } + + public V computeIfAbsent(K key, Function mappingFunction) { + if (!inRange(key)) { + if (mappingFunction.apply(key) == null) return null; + throw new IllegalArgumentException("key out of range"); + } + return m.computeIfAbsent(key, mappingFunction); + } + + public V compute(K key, BiFunction remappingFunction) { + if (!inRange(key)) { + if (remappingFunction.apply(key, null) == null) return null; + throw new IllegalArgumentException("key out of range"); + } + return m.compute(key, remappingFunction); + } + + public V computeIfPresent(K key, BiFunction remappingFunction) { + return !inRange(key) ? null : m.computeIfPresent(key, remappingFunction); + } + public final V get(Object key) { return !inRange(key) ? null : m.get(key); }