How can I call a static method of a subclass from a static method of the parent class?
class A {
static foo(){
// call subclass static method bar()
}
}
class B extends A {
static bar(){
// do something
}
}
B.foo()
Update:
The reason why I tried this is that subclasses of A would have worked best as singletons in my context and I wanted to use the template method pattern in A.
Since it looks like I cannot get a reference to a subclass from a static context I am now exporting instances of subclasses of A which works just as well. Thanks.
Update 2
Yes, it is a duplicate to a degree (the other question does not involve subclassing). The reference, even from a static context, is this
. So this works:
static foo(){
this.bar();
}