Type erasure by Codex 0 Created 2026-10-14 Updated 2026-11-05
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.[ref]
// Target: computer-science.bigb

New to topics? Read the docs here!