In computing, reification has come to mean an explicit representation of a type—that is, run-time type information.
oracle tutorials says ,
A reifiable type is a type whose type information is fully available at runtime. This includes primitives, non-generic types, raw types, and invocations of unbound wildcards.
Non-reifiable types are types where information has been removed at compile-time by type erasure — invocations of generic types that are not defined as unbounded wildcards.
A type is reifiable if it is one of the following:
- A primitive type (such as
int
) //understood- A nonparameterized class or interface type (such as
Number
,String
, orRunnable
) // why- A parameterized type in which all type arguments are unbounded wildcards (such as
List<?>
,ArrayList<?>
, orMap<?, ?>
) // why- A raw type (such as
List
,ArrayList
, orMap
) // why- An array whose component type is reifiable(such as
int[]
,Number[]
,List<?>[]
,List[]
, orint[][]
) // why
A type is not reifiable if it is one of the following:
- A type variable(such as
T
) // why- A parameterized type with actual parameters (such as
List<Number>
,ArrayList<String>
, orMap<String, Integer>
) // why- A parameterized type with a bound (such as
List<? extends Number>
orComparable<? super String>
) // why
Why 2,3,4,5 is reifiable and 6,7,8 as non-reifiable?
A reifiable type is a type whose type information is fully available at runtime. This includes primitives, non-generic types, raw types, and invocations of unbound wildcards.
Type erasure is a process in which compiler replaces a generic parameter with actual class or bridge method. In type erasure, compiler ensures that no extra classes are created and there is no runtime overhead.
Sun/Oracle says the reason is combo of:
Type erasure ensures that no new classes are created for parameterized types; consequently, generics incur no runtime overhead.
In short, 1-5 are reifiable because they simply remain the same types as specified in the code so there is no type information lost/erased, but 6-8 will lose type information during compilation (the stuff between the <>) so can't be accessed at runtime.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With