The term "type erasure" is used a bit loosely. To some it refers to the removal of generic types (i.e., angle brackets) from the code by the javac compiler (but the generic information is still kept in the class file itself--it's a common misconception that no generic information is available in the class file); to others it refers to the discarding of generic types when the class file is compiled or interpreted at runtime. Neal Gafter himself used it both ways in two different blog entries (9/23/2004 and 11/5/2006). To me erasure is really the discarding of these types at runtime, since this is really at the heart of the majority of complaints about generics.
Comments
dzonelurker replied ago:
"generic type information is erased at runtime--a process referred to as type erasure--when the .class file is compiled."
An expert, obviously.
bspies replied ago:
The term "type erasure" is used a bit loosely. To some it refers to the removal of generic types (i.e., angle brackets) from the code by the javac compiler (but the generic information is still kept in the class file itself--it's a common misconception that no generic information is available in the class file); to others it refers to the discarding of generic types when the class file is compiled or interpreted at runtime. Neal Gafter himself used it both ways in two different blog entries (9/23/2004 and 11/5/2006). To me erasure is really the discarding of these types at runtime, since this is really at the heart of the majority of complaints about generics.
Voters For This Link (15)
Voters Against This Link (2)