Unrecognized parental parent field when subclassing a general class without specifying a type

Why, when subclassing a generic class without specifying a type, does every other common type of the parent class be considered a simple type in subclasses?

For example, the following gives an error since s is not a Map <Integer, String>, but a simple map.

class Foo<T> {
    protected Map<Integer, String> s;
}

class Bar extends Foo {
    public Bar() {
        s.get(0).length();
    }
}

Of course, if Bar extends Foo <Whatever happens, the error disappears.

+4
source share
1 answer

In the Java Language Specification, Section §4.8 :

. , . super .

, . :

length() - undefined Object

+4

All Articles