changeset 7613:571a828ffc94

Collections.synchronizedMap should override all default methods.
author psandoz
date Tue, 12 Mar 2013 14:48:50 +0100
parents 35063788660b
children a89351237ea6
files src/share/classes/java/util/Collections.java
diffstat 1 files changed, 27 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/util/Collections.java	Tue Mar 12 12:29:50 2013 +0100
+++ b/src/share/classes/java/util/Collections.java	Tue Mar 12 14:48:50 2013 +0100
@@ -31,6 +31,7 @@
 import java.util.function.BiConsumer;
 import java.util.function.BiFunction;
 import java.util.function.Consumer;
+import java.util.function.Function;
 import java.util.function.Predicate;
 import java.util.function.UnaryOperator;
 
@@ -2127,12 +2128,38 @@
             synchronized (mutex) {return m.toString();}
         }
 
+        // Default methods
+
         public void forEach(BiConsumer<? super K, ? super V> action) {
             synchronized (mutex) {m.forEach(action);}
         }
         public void replaceAll(BiFunction<K, V, V> function) {
             synchronized (mutex) {m.replaceAll(function);}
         }
+        public V putIfAbsent(K key, V value) {
+            synchronized (mutex) {return m.putIfAbsent(key, value);}
+        }
+        public boolean remove(Object key, Object value) {
+            synchronized (mutex) {return m.remove(key, value);}
+        }
+        public boolean replace(K key, V oldValue, V newValue) {
+            synchronized (mutex) {return m.replace(key, oldValue, newValue);}
+        }
+        public V replace(K key, V value) {
+            synchronized (mutex) {return m.replace(key, value);}
+        }
+        public V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) {
+            synchronized (mutex) {return m.computeIfAbsent(key, mappingFunction);}
+        }
+        public V computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
+            synchronized (mutex) {return m.computeIfPresent(key, remappingFunction);}
+        }
+        public V compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
+            synchronized (mutex) {return m.compute(key, remappingFunction);}
+        }
+        public V merge(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
+            synchronized (mutex) {return m.merge(key, value, remappingFunction);}
+        }
 
         private void writeObject(ObjectOutputStream s) throws IOException {
             synchronized (mutex) {s.defaultWriteObject();}