6 ms·
I guess it's one thing to claim Java generics have problems and another to claim they are "useless". They are a big improvement over not having generics and, i
by the_af 10y ago
I guess it's one thing to claim Java generics have problems and another to claim they are "useless".
They are a big improvement over not having generics and, in my experience, one seldom sees those workarounds you mentioned. Sure, when they are necessary they are ugly... but how often are they needed in standard application code?
- kodfodrasz 10y agoLast week wanted to use GSON in a generic method to deserialize to a type which is generic type parameter, in a method of the abstract base class. Unfortunately it could not be done without the implementations passing up their .class via super constructor. IMHO deserializing JSON is quite a common application code. If you are really interrested I'd create example code, but (as being lazy, and the mentioned code not being my property) I'd hope to take my word for granted :) edit: I wrote useless in many cases!
- deleted 10y ago[deleted]
- slantedview 10y agoThere are ways to resolve generics declared on base classes: https://github.com/jhalterman/typetools https://github.com/jhalterman/typetools ...but proper support of reified generics certainly would have been better.
- dpark 10y ago> I guess it's one thing to claim Java generics have problems and another to claim they are "useless". I guess that's why the original comment said useless in many cases. Not completely useless. The next sentence also said they are way better than no generics.