I have the following legacy class that I can not change:
import java.util.logging.Logger;
public class SuperClass
{
// ...
public Logger getLogger(Class c) {
// ...
}
}
I want to override the getLogger method in my class. Is it possible to do it without raw type usage?
As mentioned in the comments, you cannot override. It also makes sense, because overriding simply means Whatever that can be done with super-class can also be done with sub-class. If SuperClass
getLoggercan takeClass(of all kinds) then the sub-class should also allow that.In this case, you could create bridge methods if that fits your purpose:
And this class can be used through out.