user2336315 user2336315 - 10 days ago 7
Java Question

Eclipse internal compiler error

When using this code in Eclipse:

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Test {
public static void main(String[] args) {
List<Object> objs = Arrays.asList(new Object(), new Object());
Set<String> s = objs.stream().collect(HashSet::new, HashSet::add, Object::toString);
System.out.println(s);
}
}


I get:

Internal compiler error: java.lang.ArrayIndexOutOfBoundsException: 0 at
org.eclipse.jdt.internal.compiler.lookup.ConstraintExpressionFormula.reduceReferenceExpressionCompatibility(ConstraintExpressionFormula
.java:273)


I know that this is this line which is producing the error:

Set<String> s = objs.stream().collect(HashSet::new, HashSet::add, Object::toString);


Not sure if it's relevant but I'm using:


  • Eclipse Kepler 4.3.2

  • Plugins: Eclipse Java Development Tools Patch with Java 8 support (for Kepler SR2) and Eclipse Plug-in Development Environment Patch with Java 8 support (for Kepler SR2)

  • java.runtime.version=1.8.0-b132



Here's the screenshot:

enter image description here

I know that the collect method is not correct but why I don't have a compiler error telling something like:

- The method collect(Supplier<R>, BiConsumer<R,? super Object>, BiConsumer<R,R>) in the type Stream<Object> is not applicable for the arguments etc.

Answer

This looks like Eclipse bug 433085 a duplicate of bug 430766. This is targeted to be fixed in Eclipse 4.4 Luna M7.

Comments