Java Reference
In-Depth Information
types. Given a generic type declaration G < T extends B > , G <?> is roughly analog-
ous to Some X <: B. G < X > .
Historically, wildcards are a direct descendant of the work by Atsushi Igarashi and
Mirko Viroli. Readers interested in a more comprehensive discussion should refer to
On Variance-Based Subtyping for Parametric Types by Atsushi Igarashi and Mirko
Viroli, in the Proceedings of the 16th European Conference on Object Oriented Pro-
gramming (ECOOP 2002) . This work itself builds upon earlier work by Kresten
Thorup and Mads Torgersen ( Unifying Genericity , ECOOP 99), as well as a long tra-
dition of work on declaration based variance that goes back to Pierre America's work
on POOL (OOPSLA 89).
Wildcards differ in certain details from the constructs described in the aforementioned
paper, in particular in the use of capture conversion (§ 5.1.10 ) rather than the close op-
eration described by Igarashi and Viroli. For a formal account of wildcards, see Wild
FJ by Mads Torgersen, Erik Ernst and Christian Plesner Hansen, in the 12th workshop
on Foundations of Object Oriented Programming (FOOL 2005).
4.5.2. Members and Constructors of Parameterized Types
Let C be a generic class or interface declaration with type parameters A 1 ,..., A n , and let
C < T 1 ,..., T n > be an invocation of C , where, for 1 ≤ i n , T i are types (rather than wildcards).
Then:
• Let m be a member or constructor declaration (§ 8.2 , § 8.8.6 ) in C , whose type as
declared is T .
The type of m in C < T 1 ,..., T n > is T [ A 1 := T 1 ,..., A n := T n ] .
• Let m be a member or constructor declaration in D , where D is a class extended by
C or an interface implemented by C . Let D < U 1 ,..., U k > be the supertype of
C < T 1 ,..., T n > that corresponds to D .
The type of m in C < T 1 ,..., T n > is the type of m in D < U 1 ,..., U k > .
If any of the type arguments in the invocation of C are wildcards, then:
• The types of the fields, methods, and constructors in C < T 1 ,..., T n > are the types of
the fields, methods, and constructors in the capture conversion (§ 5.1.9 ) of
C < T 1 ,..., T n > .
• Let D be a (possibly generic) class or interface declaration in C . Then the type of D
in C < T 1 ,..., T n > is D where, if D is generic, all type arguments are unbounded wild-
cards.
Search WWH ::




Custom Search