3 ms·
You probably know this, but it's not obvious to the random reader. Even generic types are available in the Java .class file and are accessible from the reflect
by The_Colonel 7y ago
You probably know this, but it's not obvious to the random reader.
Even generic types are available in the Java .class file and are accessible from the reflection API. Spring for example uses this quite heavily.
- cogman10 7y agoIt depends on where you are at. Type information is present in fields and class inheritance For example, a class like this `class Foo implements Bar<String>` Retains the fact that the generic type is a String. That information is completely lost at method invocation. So a method that takes a `Bar<String>` ultimately compiles to a method that takes a `Bar` and knows nothing of the String. To get that generic information down you have to engage in some fun tricks using either the class or field method I mentioned earlier. (Usually you do this with a second type parameter where it matters).