In a bunch o’ places in my code, I have something like this:
public Class mySpecialMethod() { return MySpecialClass.class; }
which causes the warning
Class is a raw type. References to generic type Class should be parameterized.
But, if I replace
Class
with
Class<? extends Object>
the warning goes away.
Is this simple practice ok, or could it cause trouble later?
It’s the correct thing to do only if there really is no common base class or interface that the Class object needs to represent.
Also
Class<?>is effectively the same asClass<? extends Object>.