As a followup to this question, first the background
Given a class with this declaration:
public class SomeClass<T>
And a subclass that does not use the generic parameter:
public class SomeSubClass extends SomeClass
A method on SomeClass declared as follows:
protected Map<String, Object> getMap(Object param) {
}
If the subclass calls the method like this:
Map<String, Object> val = getMap(param);
The compiler complains in essence that getMap returns a plain Map and there is an unchecked assignment to a genericized Map. Why is this the case? Is this a documented expectations with Generics, and is there a reason for it?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…