Re:Java Generics FAQs
by narrator on Thursday April 16, 2015 @09:38PM
(#9391824)
The key thing to remember is that generics are just for the compiler. There isn't anything actually embedded in the bytecode that knows what type a generic is.
[ Parent
| on HN ]
This is only partially true. Generic types are accessible through the reflection API. What you are referring to is type erasure.
See for yourself: https://gist.github.com/nicobn/8135faeda058fef5b6b9
Re:Java Generics FAQs
by slantedview on Friday April 17, 2015 @01:04AM
(#9392341)
Generics are captured in various places in bytecode - most importantly in type definitions. This is how the common type token pattern is exploited. Where generics are erased is in local variable declarations.