user2336315
user2336315

Reputation: 16067

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:

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.

Upvotes: 2

Views: 4909

Answers (1)

greg-449
greg-449

Reputation: 111142

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

Upvotes: 2

Related Questions