编译器IntelliJ和Eclipse之间的区别

emm*_*mby 1 java eclipse intellij-idea

我有一个如下所示的课程.这个类在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 {
        ...
    }

    ...

}
Run Code Online (Sandbox Code Playgroud)

但是,如果我尝试在IntelliJ 9中编译,我会收到编译错误.它只会在编译的IntelliJ如果我更换所有的引用<Callable<T>><? extends Callable<T>>.例如:

    public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException {
        ...
    }
Run Code Online (Sandbox Code Playgroud)

不幸的是,如果我再次尝试在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
Run Code Online (Sandbox Code Playgroud)

有没有办法可以创建一个实现的类ScheduledExectorService,它将在IntelliJ和Eclipse下编译?两个IDE似乎都配置为使用Java 1.5,这对我的部署平台是正确的.

Pas*_*ent 8

在Java 6中,ExecutorService声明以下方法(例如):

<T> T invokeAny(Collection<? extends Callable<T>> tasks)
            throws InterruptedException,
                   ExecutionException
Run Code Online (Sandbox Code Playgroud)

但是在Java 5中,同样的方法声明如下ExecutorService:

<T> T invokeAny(Collection<Callable<T>> tasks)
            throws InterruptedException,
                   ExecutionException
Run Code Online (Sandbox Code Playgroud)

我没有安装Java 5,也无法使用Eclipse Java EE Galileo 20090920-1017重现错误(我在Ubuntu下并且sun-java5-jdk已经从Karmic的存储库中删除了,我懒得安装它手动)但实际上,我认为Eclipse是对的.

您确定在IntelliJ IDEA中使用JDK 5(而不是符合1.5级的JDK 6)吗?