Closed
Description
Java 8:
scala> import java.util.Properties
import java.util.Properties
scala> new Properties().putAll(new Properties)
Java 9:
scala> import java.util.Properties
import java.util.Properties
scala> new Properties().putAll(new Properties)
<console>:13: error: ambiguous reference to overloaded definition,
both method putAll in class Properties of type (x$1: java.util.Map[_, _])Unit
and method putAll in class Hashtable of type (x$1: java.util.Map[_ <: Object, _ <: Object])Unit
match argument types (java.util.Properties)
new Properties().putAll(new Properties)
The reason is that the following override was added in Java 9 in order to use a ConcurrentHashMap as the underlying implementation:
@Override
public synchronized void putAll(Map<?, ?> t) {
map.putAll(t);
}
scalac seems to think it's an overload instead of an override. The Hashtable method is defined as (K = Object and V = Object):
public synchronized void putAll(Map<? extends K, ? extends V> t) {
for (Map.Entry<? extends K, ? extends V> e : t.entrySet())
put(e.getKey(), e.getValue());
}
I found this while trying to compile Apache Kafka with Java 9.
Is it worth doing anything about this apart from documenting it somewhere?