Community
Participate
Working Groups
N20050518-0010: Steps to reproduce: - Create simple Java project using workspace settings - Create cu import java.util.Collection; public class Test { Collection<String> c; public Test() { super(); } } - Invoke 'Generate Delegate Method', select only addAll - Generate delegate results in public boolean addAll(Collection<? extends String> c) { return c.addAll(c); } -> Compile error The method addAll(Collection<? extends capture-of ? extends String>) in the type Collection<capture-of ? extends String> is not applicable for the arguments (Collection<capture-of ? extends String>) although the generated code is correct Attaching workspace preferences
Created attachment 21337 [details] workspace preferences
I also encountered a similar error when moving up from 3.1M6 to 3.1RC2. I have several source files that no longer compile. Here is a simple test case that demonstrates the problem: import java.util.ArrayList; import java.util.List; public class Test { void foo() { List<? extends Number> s = new ArrayList<Number>(); List<? extends Number> t = new ArrayList<Number>(); s.addAll(t); // <-- Generates bogus error message } }
javac agrees with us on latter case: Test.java:7: cannot find symbol symbol : method addAll(java.util.List<capture of ? extends java.lang.Number>) location: interface java.util.List<capture of ? extends java.lang.Number> s.addAll(t); // <-- Generates bogus error message ^ 1 error Basically, captures exhibits the fact that a wildcard denotes 'some' type, but not any type. See litterature on wildcards or JLS 3rd edition for more details.
I cannot reproduce original issue with latest. Closing, pls reopen if you still see a problem.