No, unfortunately it is not possible to use generic extends
with a generic type and an interface. In fact, it is not even possible to use generic extends
with multiple types. If you could, then you could do something like the following.
class Test<T, B extends Serializable> {
public <Z extends T & B> void method(Z test) {
...
}
}
This restriction against extending multiple types may be because of type erasure. At runtime the generics are removed and public <Z extends Serializable>
simply becomes public Serializable
. So what would <Z extends T & Serializable>
be replaced with?