Type erasure (source code)

= Type erasure
{wiki}

In <Java>, <type erasure> implements generic code by replacing a type parameter with its bound, or `Object` if unbounded, while inserting required casts and bridge methods. Thus `List<String>` and `List<Integer>` share a runtime list class even though the compiler checks different element types. Some generic type information remains in metadata for reflection, so erasure does not mean every trace of generic declarations disappears. Restrictions such as the inability to directly create `new T()` follow from the absence of a distinct reified runtime class for arbitrary type arguments.https://docs.oracle.com/javase/tutorial/java/generics/erasure.html[Oracle, Type Erasure: replacement, casts and bridge methods]{ref}

// Target: computer-science.bigb