【发布时间】:2009-12-01 18:14:47
【问题描述】:
我有一个如下所示的课程。此类在 Eclipse build 20090920-1017 上编译良好:
public class MyScheduledExecutor implements ScheduledExecutorService {
...
public <T> List<Future<T>> invokeAll(Collection<Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException {
...
}
public <T> List<Future<T>> invokeAll(Collection<Callable<T>> tasks) throws InterruptedException {
...
}
public <T> T invokeAny(Collection<Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
...
}
public <T> T invokeAny(Collection<Callable<T>> tasks) throws InterruptedException, ExecutionException {
...
}
...
}
但是,如果我尝试在 IntelliJ 9 中编译,则会出现编译错误。如果我将所有对<Callable<T>> 的引用替换为<? extends Callable<T>>,它只会在IntelliJ 中编译。例如:
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException {
...
}
不幸的是,如果我再次尝试在 Eclipse 中重新编译修改后的类,则会出现编译错误。
Name clash: The method invokeAll(Collection<? extends Callable<T>>) of type
SingleScheduledExecutor has the same erasure as invokeAll(Collection<Callable<T>>) of
type ExecutorService but does not override it
有什么方法可以创建一个实现ScheduledExectorService 的类,该类将在 IntelliJ 和 Eclipse 下编译?两个 IDE 似乎都配置为使用 Java 1.5,这对于我的部署平台是正确的。
【问题讨论】:
标签: java eclipse intellij-idea