PMD rule says:
Calling redefined methods during construction creates the risk of calling methods on an incompletely constructed object and can be difficult to debug. This can lead to the fact that the subclass will not be able to build its own superclass or is forced to completely reproduce the building process inside itself, having lost the ability to call super() . If the default constructor contains a call to an overridden method, the subclass can be completely irreversible. Note that this includes method calls throughout the control flow graph β that is, if the constructor Foo() calls the private method bar() , which calls the public method buz() , this means a problem.
Example:
public class SeniorClass { public SeniorClass(){ toString();
Decision
Remove any call to overridden methods in the constructor or add the final modifier to these methods.
Paul vargas
source share