What is erasure
What is erasure and what is the restrictions of erasure on 开发者_C百科generics?
Erasure is the result of types being used at compile time and not being present at runtime. This is a common issue in Java Generics. The main issue is that at runtime you are unable to determine the type a generic class contains. For example if you have
ArrayList<Foo> t;
It is not possible to get the type, Foo
, the ArrayList
contains using reflection at runtime.
Here is a good explanation: http://download.oracle.com/javase/tutorial/java/generics/erasure.html
精彩评论