I need to call a superclass static method on a subclass and be aware that it was called on a subclass. The following code shows the use case, please notice the method invocation on a subclass B.importantMethod()
and the place where I need to know that it was called on subclass: //would like to get B here
.
class A {
public static void importantMethod() {
System.out.println("???"); //would like to get B here
}
}
class B extends A {
//no implementation, just inheritance
}
public class Test {
public static void main(String[] args) {
B.importantMethod();
}
}
Any possible way of achieving this will be good for me. My tries ended up with nothing, I always get A
, not B
.