I am creating a generic class (TestGeneric) with 2 type parameter (TAnimal and TMammal), with the 2nd type parameter (TMammal) extending the 1st type parameter (TAnimal) and another type (Mammal).
public class TestGeneric<TAnimal extends Animal, TMammal extends TAnimal & Mammal> { .. }
where
public interface Animal { ... }
public class Mammal implements Animal { ... }
I am getting this Java problem:
Cannot specify any additional bound Mammal when first bound is a type parameter.
If I swap the bounded type TAnimal & Mammal around,
public class TestGeneric<TAnimal extends Animal, TMammal extends Mammal & TAnimal> { .. }
I am getting another Java problem:
The type TAnimal is not an interface; it cannot be specified as a bounded parameter.
Is there anyway to overcome the above mentioned limitation in Java?
I am using Java 1.8-172.