Community
Participate
Working Groups
Build Identifier: 20090621-0832 2 captures of a same class parametized with <?> raise a compilation error under Eclipse but compile OK with javac. This is not a big problem, but it has already happen many times and is a bit annoying. A workaround is to remove the generic and to cast it to the "ungeneralized" class and to add a suppressWarning to avoid a compilation warning. Reproducible: Always Steps to Reproduce: 1. Create the following interfaces public interface Task<T> { Collection<TaskListener<T>> getListeners(); } public interface TaskListener<T> { } 2. Now in a new class, try the following code : for (final Task<?> task : tasks) { for (final TaskListener<?> listener : task.getTaskListeners()) { // Following code raise a compilation error : // he method taskFailed(Task<capture#12-of ?>) in the type TaskListener<capture#12-of ?> is not applicable for the arguments (Task<capture#13-of ?>) listener.taskFailed(task, e); } } 3. Try to compile it with javac: it works
Please attach a code snippet that shows the problem. In the comment 0, 'e' is not defined. The listener interface doesn't define any method. Thanks.
Hello Christophe, Per comment#1 can you post a small but full program that shows the problem ? As it is, we can make no progress whatsoever and will have to close this as WORKSFORME.
The following program elicits a very similar warning from eclipse, but it also gets the same warning from javac5,6,7. import java.util.Collection; interface Task<T> { Collection<TaskListener<T>> getTaskListeners(); } interface TaskListener<T> { void taskFailed(Task<T> task); } public class Test { public void driver(Collection<Task<?>> tasks){ for (final Task<?> task : tasks) { for (final TaskListener<?> listener : task.getTaskListeners()) { listener.taskFailed(task); } } } }
Please reopen if a test case becomes available. The posted incomplete code snippet when "reasonably" completed via quick fixes results in code which is treated identically by eclipse as by javac as shown by comment#3
Verified for 3.6M6 using build I20100305-1011.
Verified
Sorry, back from holidays... While trying to extract a small test case I was not able to reproduce this problem either. This must be related to a specific use case. As soon as I reproduce it, I will re-open it. Until then, keeping it closed is fine. Sorry for the lack of feedbacks