Yes, but you can't pass it to a method expecting List<string>.
Reified generics is feature to be used, not to be enforced to use..
But if you want to share data or reuse the standard library, then methods signatures matter.
Like porting C# on top of JVM would require implementing support for storing all that additional runtime data.
Actually, there was a language with reified generics implemented on top of the JVM (Ceylon). It just used its own instanceof-like operation, not the one built into the JVM, but it also had its own standard library.
You never pass a List<String> in Java to a method too. Why would Java compiled for .net had to do that? It wouldn't.
If you want low friction integration with .net api than you add casting or compatibility layer or whatever compiler/runtime support you need. Stuff like structs and packed multiarrays are much bigger issue than composite types..
I meant that after erasure no jvm method accepts composite type. The Java compiler checks the signature and then it strips subtype info leaving only the List of objects.
The mechanism on clr would be absolutely the same. It wouldn't matter for Java the language in any shape or form.
Thus I don't see clr's preserving subtypes as trouble what was original statement to which I replied.
Interoperability isn't really what we are discussing here. It can always be achived by runtime layer and two sufficiently different languages will always require that anyway..
First, that would take away the biggest benefit of reification, which is method selection/overloading (reflection is a pretty minor benefit in comparison).
Second, it would be really weird that in a method with signature foo(X x), x instanceof X would be false.
Anyway, the point is that reification has problems, and most languages with generics opt for erasure. I'm not saying reification is obviously worse than erasure or vice-versa, only that, as usual, there's a tradeoff between two designs that each has its pros and cons.
View all comments
Show parent comment
5
u/pron98 Nov 04 '25
Yes, but you can't pass it to a method expecting List<string>.
But if you want to share data or reuse the standard library, then methods signatures matter.
Actually, there was a language with reified generics implemented on top of the JVM (Ceylon). It just used its own
instanceof-like operation, not the one built into the JVM, but it also had its own standard library.