I have an abstract class for testing subclasses of a parent class.

class ParentTest<T extends Parent> {

    ParentTest(final Class<? extends T> childClass) {
        super();
        this.childClass = requireNonNull(childClass, "childClass is null");
    }

    protected final Class<? extends T> childClass;
}

Now a child class has it's own type parameters.

class ChildTest<T> extends ParentTest<ChildClass<T>> {

    ChildTest() {
        super(Child.class); // @@? error
        super(Child<T>.class); // @@? error
    }
}

The only only working way I found is this.

class ChildTest<T> extends ParentTest<ChildClass> { // << !!

    ChildTest() {
        super(Child.class);
    }
}

Is this normal?

0 Answers