Because Generic<T> not a subtype of Generic<A> , even if T is a subtype of A
To illustrate this, consider a String instance of Object :
List<String> listOfStrings = new ArrayList<String>(); List<Object> listOfObjects = (List<Object>)listOfStrings;
The compiler does not allow this because it can damage the original list. The JVM does not apply general runtime requirements to boundaries.
The solution here is to declare the field type c as' Generic`.
source share