Reputation: 21
What is erasure and what is the restrictions of erasure on generics?
Upvotes: 2
Views: 209
Reputation: 7353
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.
Upvotes: 3
Reputation: 16757
Here is a good explanation: http://download.oracle.com/javase/tutorial/java/generics/erasure.html
Upvotes: 1