Re:JITs are un-ergonomic
by The_Colonel on Sunday March 29, 2020 @08:56AM
(#22718605)
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.
It 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).
You're thinking about generics. .class files preserve a whole bunch of type information (I'm building a .class decompiler in my free time, and I'm looking at that very same data in my debugger ATM).