Java Reference
In-Depth Information
This is of no consequence, as it is impossible to access a member of a paramet-
erized type without performing capture conversion (§ 5.1.10 ) , and it is impos-
sible to use a wildcard type after the keyword new in a class instance creation
expression.
The sole exception to the previous paragraph is when a nested parameterized
type is used as the expression in an instanceof operator (§ 15.20.2 ), where cap-
ture conversion is not applied.
4.6. Type Erasure
Type erasure is a mapping from types (possibly including parameterized types and type
variables) to types (that are never parameterized types or type variables). We write | T | for
the erasure of type T . The erasure mapping is defined as follows:
• The erasure of a parameterized type (§ 4.5 ) G < T 1 ,..., T n > is | G |.
• The erasure of a nested type T . C is | T |. C .
• The erasure of an array type T [] is | T | [] .
• The erasure of a type variable (§ 4.4 ) is the erasure of its leftmost bound.
• The erasure of every other type is the type itself.
Type erasure also maps the signature (§ 8.4.2 ) of a constructor or method to a signature that
has no parameterized types or type variables. The erasure of a constructor or method sig-
nature s is a signature consisting of the same name as s and the erasures of all the formal
parameter types given in s .
The type parameters of a constructor or method (§ 8.4.4 ) , and the return type (§ 8.4.5 ) of a
method, also undergo erasure if the constructor or method's signature is erased.
The erasure of the signature of a generic method has no type parameters.
4.7. Reifiable Types
Because some type information is erased during compilation, not all types are available at
run time. Types that are completely available at run time are known as reifiable types .
A type is reifiable if and only if one of the following holds:
• It refers to a non-generic class or interface type declaration.
• It is a parameterized type in which all type arguments are unbounded wildcards
4.5.1 ) .
Search WWH ::




Custom Search