In Java, type erasure is the process where the compiler removes all information related to type parameters and type arguments within a class or method when a generic type is instantiated. In C++ type erasure refers to a technique for hiding some or all of the type information regarding a class.
In Java, generics are checked at compile-time for type-correctness. The generic type information is then removed in a process called type erasure.
As an example, Box<String>
is translated to type Box, which is called the raw type.
Type erasure enables Java applications that use generics to maintain binary compatibility with Java libraries and applications that were created before generics.
See Oracle's Java Tutorial on Type Erasure for more information, as well as the Wikipedia entry on Problems with Type Erasure.
In C++ type erasure is a technique to hide some or all of the type information regarding a class (e.g. boost::any).