"java: Duplicate methods named XXX" when using the Eclipse compiler in IDEA with JDK 8

Using the following simple class, I get a java: Duplicate methods named spliterator with the parameters () and () are inherited from the types java.util.List<T> and java.lang.Iterable<T> error java: Duplicate methods named spliterator with the parameters () and () are inherited from the types java.util.List<T> and java.lang.Iterable<T> when using the Eclipse compiler in IDEA with JDK 8:

 public class Java8Test { public static interface Traverable<T> extends Iterable<T> {} public static interface List<T> extends Traverable<T>, java.util.List<T> {} } 

If you change the compiler to javac, then there is no error. The error also disappeared when switching to JDK 6 with the eclipse compiler.

IDEA Version: 12.1.5

+6
source share
2 answers

I got the same error while trying to compile Java 7 code with Java JDK.

The solution that worked for me is to change the JRE configured in Eclipse to Java 7: Window -> Preferences -> Java -> Installed JREs . Edit the existing one and select the directory containing the Java 7 JDK.

+4
source

I had the same problem. It seems that the Eclipse 4.3 JTD works well with Java8. According to Stefan Herrmann (CLA):

The Java 7 compiler should never try to compile JRE 8. True compatibility for the script is not specified anywhere and cannot even be possible due to the default methods that were added to the libraries in such a way as to ensure compatibility of the old code of old time but not compile time compatibility with the Java 7 compiler and new libraries. Therefore, I mark this error as invalid, it is st we cannot support design.

You can read here:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=407010

and here:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=409473

https://bugs.eclipse.org/bugs/show_bug.cgi?id=390889

0
source

Source: https://habr.com/ru/post/955103/


All Articles