Multilevel Java generic inheritance using extends on generic parameters

Viewed 18528

I have

public class First<T> {}

public class Second<T extends SomeConcreteClass> extends First<T> {}

public class Third<T> extends Second<T> {} //Compile-time error

I get the compile-time error

Type argument T is not with bounds of type-variable T.

When I contruct a Third, I want to be able to give the generic parameter as SomeConcreteClass (or derived class thereof), and for a run-time error to be thrown if I've offered up a type that is not part of SomeConcreteClass's inheritance hierarchy.

I would think that the specification in Second's declaration would simply propagate downward, i.e. it should be implicit in the declaration (and any instantiations) of Third.

What's with the error?

4 Answers
Related