Hi,
I want to dynamically find out the type of a template parameter
of a generic class. E.g. suppose I've got a variable myCollection
of type LinkedList<String>. Then I would like to be able to find out
"String" when I only have myCollection.
Looking at the 1.5 API, I would have expected this to work:
myCollection.getClass().getTypeParameters().
There seems to be one Type Parameter indeed, but it is called "E"
instead of "String". Is this intended behaviour?
Looking at the spec, it seems that although in principle generics
information is compiled away, it *is* available at runtime via a
classfile attribute called "signature". However, I can't seem to
find out how this can be accessed.
Odd part is, though, that the spec says this attribute was added in order
for reflection to work properly. As shown above, however, this does not
seem to be the case.
Is something wrong here, or did I just misunderstand?
Thanks,
Hans