@Override and default methods

Paul Benedict pbenedict at apache.org
Wed Nov 13 17:43:45 PST 2013


I saw this email come through Apache and would like your opinions:

===
Hi,

during the vote for collections 4.0 we have discovered a problem wrt the
MultiMap interface in general and specifically the MultiKeyMap.

Java 8 introduces a new default method in the Map interface:

 boolean remove(Object key, Object value)

This clashes with the method in MultiMap:

 V remove(K key, V value)

and the remove methods for multiple keys in MultiKeyMap:

 V remove(K key1, K key2)

Just changing the return type does not solve the problem, as one can not
re-define a method in an interface without using the @Override
annotation, but this would only work when compiling with JDK 8 and fail
for other JDKs.
===

What is the correct course in such a situation?

-- 
Cheers,
Paul


More information about the lambda-dev mailing list