简体   繁体   中英

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:

在此处输入图片说明

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM