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
List<String>
is any different from aList<Long>
. 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 newArrayList<String>()
is really just a newArrayList()
at runtime, if a class extendsArrayList<String>
, then the JVM knows thatString
is the actual type argument forList
's type parameter.
and Neal Gafter's blog.