I have some code which comiles using Java 8's javac but not eclipse.
Here is an example:
@FunctionalInterface
public interface Accumalator<E> {
void acum(Container<E> container, E data);
}
public interface Container<E> {
public void add(E data);
@SuppressWarnings("unchecked")
public void add(E...data);
}
public class Binding<E> {
private final Accumalator<E> function;
public Binding() {
function = Container::add;
}
}
The compiler compains about the method reference "Container:add" with the message "Cannot make a static reference to the non-static method add(Object[]) from the type Container".
Removing the overloaded method "public void add(E...data)" on Container resolves the compiler error which is why I beleive it's the cause. Anyhow, when I use javac I am able to compile the code (with the overloaded varargs method) without a problem.
[Updated on: Mon, 28 July 2014 13:11]
Report message to a moderator