Reputation: 2031
Code snippet is this:
package test;
import java.util.Collection;
import java.util.LinkedList;
import java.util.concurrent.*;
public class Test {
public static void main(String[] args) {
Callable<?> callable;
final ExecutorService someExecutor = null;
Collection<Callable<?>> tasks = new LinkedList<Callable<?>>();
int timeoutInSeconds = 10;
try {
for (Future<?> f : someExecutor.invokeAll(
(Collection<? extends Callable<Callable<?>>>) tasks,
timeoutInSeconds, TimeUnit.SECONDS)) {
f.get();
}
} catch (java.util.concurrent.CancellationException e) {
} catch (Exception e) {
e.printStackTrace();
}
}
}
When I compile from command line
javac Test.java
I get the following error:
Test.java:17: inconvertible types
found : java.util.Collection<java.util.concurrent.Callable<?>>
required: java.util.Collection<? extends java.util.concurrent.Callable<java.util.concurrent.Callable<?>>>
(Collection<? extends Callable<Callable<?>>>) tasks,
^
I also get the same error when I compile with IDEA or Netbeans. But eclipse thinks everythink is ok and runs normally. I triple checked that all 3 use the same JDK (1.6u45). So what does eclipse do differently?
Upvotes: 0
Views: 128
Reputation: 40
If you specify the JVM with -vm option in your eclipse.ini, does eclipse has the same behavior? This doesn't work.
Try navigate to Preferences->Java->Compiler->Error/Warnings, in the right panel, search "Unchecked generic type operation", set level from "Ignored" to "Error". Have a rebuilt, you will get the same result.
Upvotes: 0
Reputation: 33000
Eclipse uses an own Java compiler ECJ which sometimes behaves differently than javac
.
Upvotes: 1