Optimization of Java Generic Types
Generic types in Java are implemented using type erasure. This means that types are checked at compile time, and then code is generated that is type agnostic. The advantage is that you only need one compiled version of any bit of generic code, but the disadvantage is that the JIT compiler has lost any sort of type information that can help produce more efficient code.
This differs from the implementation of generic types as templates in C++ were a new code is generated for every unique type instantiation. The advantage of templates is that the compiler is able to optimize the code based of the types used, but the disadvantage is the increased amount of generated code.
More Info:
To find out more, check out our paper, Specialization of Java Generic Types, which was written for, and presented at MICS 2006.
Archive.org has our old wiki page, so feel free to check that out too: UMM CSci TWiki page.