javajava-8coltname-clash

Compiling failure of old library concurrent since Java 8


The math library colt (version 1.2) depends on the library EDU.oswego.cs.dl.util.concurrent (gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html). Compiling concurrent (version 1.3.4) worked on java version 7 or previous releases. However compiling fails on java 8 (javac version 1.8). Compiler options -source 1.4 -target 1.4 do not resolve the issue.

The reason is, that java 8 introduced a new method "remove" in the interface java.util.Map: default boolean remove(Object key, Object value). This new method clashes with the method "remove" in the library class ConcurrentHashMap.java which implements java.util.Map: protected Object remove(Object key, Object value).

Once the cause of the problem was identified I could resolve the issue by renaming the method in the library class ConcurrentHashMap.java. This was acceptable because the library method was protected only (and not public).

Are there other possibilities to ensure java 8 compatibility?


Solution

  • There are no compiler options nor annotations that will ignore conflicting method signatures.

    If you (or, in this case, colt) don't use the new remove method, just compile it under Java 7. Compiling it under Java 8 won't give you any advantage.

    But I actually like your solution better in this case.