I have a Parent class(from GMF to be specific) with static initializer method initDefaults
public Class Parent{
public static initDefaults(){
...
}
}
I have a custom child class that extends the Parent class
public Class CustomSubclass extends Parent{
public CustomSubclass(){
super();
..
}
}
In my calling class I am calling initDefaults
method with the CustomSubclass name i.e.,
CustomSubclass.initDefaults()
but eclipse automatically corrects this and types Parent.initDefaults()
.
public Class ExampleClass{
public void initializer(){
// CustomSubclass.initDefaults(); this is what I typed
Parent.initDefaults(); // this is what eclipse corrected
...
}
}
Both ExampleClass
and CustomSubclass
reside under same package while Parent
is from GMF as dependency.
Why is this happening? I have other plugin project with the same setup and there this is not the case and the CustomSubclass
name is retained as it is. But I did not implement the other plugin project.
Whenever I am typing the subclass name with superclass method, the superclass is automatically imported and eclipse corrects the subclass name with the superclass name.
Eclipse provides for this code smell (the compilation would not fail, but it's harder to read, a bit slower and there is no real benefit since static methods cannot be overridden):
These defaults can be overridden by the following project specific settings (tick the Enable project specific setting checkbox):