Hi, I was reading Java Generics and collections by Maurice Naftalin & Philip Wadler. I have been puzzled (and tried to search help, but couldn't any match) with this highlighted sentence on page 102 regarding reflection, arrays and generics..
Unchecked casts are required because the methods in the Java reflection library cannot return sufficiently accurate types, for various reasons. The method getComponentType is in the class Class<T>, and java provides no way to restrict the receiver type to be class<T> in the signature of the method (though the call raises an exception if the receiver is not a class token for an array type)
and here's relevant java code..
Probably something quite easy, but it's expressed quite tricky. Any help?
I'm not dead! I feel happy! I'd like to go for a walk! I'll even read a tiny ad: