Java does not allow overriding static methods. See Why Java does not allow overriding static methods?
The only thing you can do is hide the static method in a subclass. Hiding means that it does not depend on what type of object it is called, but on what type of class. See http://docs.oracle.com/javase/tutorial/java/IandI/override.html
Now the problem is that your subclass method is formally the same signature, but because of the generic types, it does not hide it. Collection<? extends ArithmeticExpression> Collection<? extends ArithmeticExpression> is neither the same nor a subtype of Collection<? extends Expression> Collection<? extends Expression> , which virtually prevents correct, unambiguous hiding. As Iobi noted, a compiler rule was introduced to ensure backward compatibility: The method has the same erasure as another method in the type
I can’t try this for myself right now, but the error should disappear if both have the same common types. Although I have no idea why the error does not occur in Java 5. I assume that they introduced this compiler rule in a later version because they had not noticed it before.
André stannek
source share