我有一个如下所示的课程.这个类在Eclipse build 20090920-1017上编译得很好:
public class MyScheduledExecutor implements ScheduledExecutorService { ... publicList > invokeAll(Collection > tasks, long timeout, TimeUnit unit) throws InterruptedException { ... } public List > invokeAll(Collection > tasks) throws InterruptedException { ... } public T invokeAny(Collection > tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { ... } public T invokeAny(Collection > tasks) throws InterruptedException, ExecutionException { ... } ... }
但是,如果我尝试在IntelliJ 9中编译,我会收到编译错误.它只会在编译的IntelliJ如果我更换所有的引用
与 extends Callable
.例如:
publicT invokeAny(Collection extends Callable > tasks) throws InterruptedException, ExecutionException { ... }
不幸的是,如果我再次尝试在Eclipse中编译修改后的类,我会收到编译错误.
Name clash: The method invokeAll(Collection extends Callable>) of type SingleScheduledExecutor has the same erasure as invokeAll(Collection >) of type ExecutorService but does not override it
有没有办法可以创建一个实现的类ScheduledExectorService
,它将在IntelliJ和Eclipse下编译?两个IDE似乎都配置为使用Java 1.5,这对我的部署平台是正确的.
在Java 6中,ExecutorService
声明以下方法(例如):
T invokeAny(Collection extends Callable > tasks) throws InterruptedException, ExecutionException
但是在Java 5中,同样的方法声明如下ExecutorService
:
T invokeAny(Collection > tasks) throws InterruptedException, ExecutionException
我没有安装Java 5,也无法使用Eclipse Java EE Galileo 20090920-1017重现错误(我在Ubuntu下并且sun-java5-jdk已经从Karmic的存储库中删除了,我懒得安装它手动)但实际上,我认为Eclipse是对的.
您确定在IntelliJ IDEA中使用JDK 5(而不是符合1.5级的JDK 6)吗?