class MyTreeMap<K extends Comparable<? super K>, V>
extends AbstractMap<K, V>
So K
is declared with a bound of extends Comparable<? super K>
. You just need to redeclare that same bound on the subclass.
class TreeMapIndexer<K extends Comparable<? super K>>
extends MyTreeMap<K, LinkedList<Integer>>
Otherwise you are attempting to declare the subtype as not having the restriction which is the compilation error 'bound mismatch'.
What you tried was almost right, the bound just needed to be in the generic type declaration, not the arguments (passed along) to the superclass.