Reputation: 20163
I have this class:
public abstract class SuperClass<
CONE extends ClassOne,
OBJ,
VOBJ extends ValidateValue<OBJ>>
which I'm trying to extend with this:
public class SubClass<CONE,VOBJ>
extends SuperClass<CONE,Object,VOBJ> {
but am getting these two errors.
type parameter CONE is not within its bound
public class SubClass<CONE,VOBJ> extends SuperClass<CONE,Object,VOBJ> {
type parameter VOBJ is not within its bound
public class SubClass<CONE,VOBJ> extends SuperClass<CONE,Object,VOBJ> {
If I change SubClass to this:
public class SubClass
extends SuperClass<ClassOne,Object,ValidateValue<Object>> {
It compiles fine.
This makes no sense to me, as I'm simply passing CONE and VOBJ up the chain.
I would appreciate some advice. This is puzzling me. Thank you.
Upvotes: 1
Views: 115
Reputation: 279940
The type parameters declared in
public class SubClass<CONE,VOBJ>
ie. ONE
and VOBJ
don't have the bounds that SuperClass
is expecting and therefore can't be used as type arguments for the parent class. It would need to be
public class SubClass<CONE extends ClassOne, VOBJ extends ValidateValue<Object>>>
extends SuperClass<CONE, Object, VOBJ> {
...
}
In your declaration that works
public class SubClass
extends SuperClass<ClassOne,Object,ValidateValue<Object>> {
you are passing type arguments that do match the bound. ClassOne
matches T extends ClassOne
and ValidateValue<Object>
matches T extends ValidateValue<F>
where F
is Object
.
Upvotes: 4