I have a class that looks like the following. This class compiles fine on 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 {
...
}
...
}
However, if I try to compile in IntelliJ 9, I get a compilation error. It will only compile in IntelliJ if I replace all references to <Callable<T>>
with <? extends Callable<T>>
. For example:
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException {
...
}
Unfortunately, if I then try to compile the modified class back in Eclipse again, I get a compilation error.
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
Is there any way I can create a class that implements ScheduledExectorService
that will compile under both IntelliJ and Eclipse? Both IDEs appear to be configured to use Java 1.5, which is correct for my deployment platform.