Community
Participate
Working Groups
Build ID: M20071023-1652 Steps To Reproduce: 1. Simply compile the following piece of sourcecode. > Test.java >>> import java.util.List; public class Test { public static void doIt(List<?> list) { list.add(list.remove(0)); } } < Test.java <<< 2. The resulting compiler message should be ### Severity and Description Path Resource Location Creation Time Id The method add(capture#1-of ?) in the type List<capture#1-of ?> is not applicable for the arguments (capture#2-of ?) @workspace/src Test.java line 5 1194516108823 1446564 ### More information: Why are there different captures of the specified wildcard. The wildcard should be captured only once and this capture should be used for the parameter type of the add method as well as the return type of the remove method (both parameters are specified by the generic type E in interface List). By capturing the wildcard, it is arbitrary but fixed, i.e., every usage of the underlying generic type E should use the same capture of the wildcard.
Unfortunately no. The spec is very clear about it. Each reference to a wildcard is captured independantly, and produces distinct types; hence the error message you get. You may be interesting in reading: http://blogs.sun.com/ahe/date/20040610 Closing as INVALID
Added GenericTypeTest#test1220
Verified for 3.4M4