I\'ve thought java erasure wipes generic types out in compile time however when i test it by myself i realized there are some information about generic types in Bytecode.
Some Generic type information is stored in Signature attributes . Refer JLS 4.8 and 4.6 and JVM spec 4.3.4. Read here:
Probably the most common complaint about generics in Java is that they are not reified - there is not a way to know at runtime that a
Listis any different from aList. I've gotten so used to this that I was quite surprised to run across Neil Gafter's work on Super Type Tokens. It turns out that while the JVM will not track the actual type arguments for instances of a generic class, it does track the actual type arguments for subclasses of generic classes. In other words, while a newArrayListis really just a new() ArrayList()at runtime, if a class extendsArrayList, then the JVM knows thatStringis the actual type argument forList's type parameter.
and Neal Gafter's blog.