I think having generics is a big step forward over not having generics - I use them a lot too. Just avoiding casts for every ArrayList get call is a big win.
I also wrote some code to read a configuration file into annotated POJOs. All the type information was there (including the type parameters). This is because the field declarations in reflection have all the type information, including the parameter types. So at the time I still did not get a feel as to what the problem really was. At this point all the "its just completely broken" comments just did resound not with me. I finally wrote some generics code where I have really hit type erasure. I have a genericised class which takes an Object as input where I want to make sure it is compatible with the type parameter. I cannot see a way of doing it. I cannot do "if (obj instanceof T)", or use reflection, or ... Pity. So I finally "feel" the type erasure problem (as distinct from just conceptually understanding it). But passing in the class to the constructor solved the problem. Not perfect, but not that hard either. This may be old hat for everyone else here - just an "ah ha!" moment for me. I agree that in a perfect world generics could have been done better, but I don't buy that they are completely broken and unusable. Its just in *some* circumstances you have to do more work yourself and the code is a bit less clean. Alan Jess Holle wrote: > Generics are really so painful? Really? > > I use them a /lot/. While having to pass Class<T> in classes where I > shouldn't have to so as to do new T(), etc, comes up sometimes and is > painful, it does not come up often and isn't /that/ painful either. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaposse?hl=en -~----------~----~----~----~------~----~------~--~---
