Prz*_*cki 10 java eclipse compiler-errors eclipse-neon
我在Sandbox.java文件中有以下类:
package sandbox;
import java.util.Arrays;
import java.util.Collection;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;
public class Sandbox {
public static void main(String[] args) throws Exception {
ExecutorService executor = Executors.newSingleThreadExecutor();
Collection<String> s = Arrays.asList(1,2,4,100).stream()
.map(i -> CompletableFuture
.supplyAsync(() -> Wrapper.of(i), executor)
.thenApply(d -> d.get().toString())
)
.map(CompletableFuture::join)
.collect(Collectors.toList());
executor.shutdown();
System.out.println(s);
}
}
class Wrapper<T> {
T t;
private Wrapper(T t) {
this.t = t;
}
public T get() {
return t;
}
public static <T> Wrapper<T> of (T t) {
return new Wrapper<>(t);
}
}
Run Code Online (Sandbox Code Playgroud)
Eclipse中的编译在第14行"无法推断map(Function)的类型参数"中显示错误.
使用纯javac(JDK 1.8.0_121)编译相同的代码没有问题.
如果我将正确的行更改为:
Collection<String> s = Arrays.asList(1,2,4,100).stream()
.map(i -> CompletableFuture
.supplyAsync(() -> Wrapper.of(i), executor)
.<String>thenApply(d -> d.get().toString())
)
.map(CompletableFuture::join)
.collect(Collectors.toList());
Run Code Online (Sandbox Code Playgroud)
那么代码在Eclipse中编译时没有错误.
有谁知道为什么会有这样的行为?这是一个错误吗?
我使用Eclipse 4.6.2.20161208-0625(它目前没有发现更新).
我已经确认,这是一个错误:https://bugs.eclipse.org/bugs/show_bug.cgi?id = 512486.它已在4.6.3中声明已解决.当稳定释放可用时,我会确认这一点.
| 归档时间: |
|
| 查看次数: |
15527 次 |
| 最近记录: |