You cannot override a static method. Therefore, when you declare the same static method, you create a new method.
public static ClassInfo<B> getClassInfo() { return new ClassInfo<B>(B.class, A.getClassInfo()); }
But, when you declare your method with a modified return type, it is not a valid method that hides not to override . Thus, the getClassInfo() method of class A and getClassInfo() class B contradict each other. Since the class A method is also displayed in class B.
So, in other words, class B has the same method as inherited from class A , with a change in return type. And since the type of the returned method is not considered part of the method signature. Hence the conflict.
So you should have exactly the same type of return. In this case, class B will ignore the inherited method and use it.
source share