...
Allowing a constructor to call overridable methods can provide an attacker with access to the this
reference before an object is fully initialized, which could lead to a vulnerability.
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
MET05-J | Medium | Probable | Medium | P8 | L2 |
Automated Detection
Automated detection of constructors that contain invocations of overridable methods is straightforward.
...
Related Guidelines
Inheritance [RIP] | |
Guideline 7-4 / OBJECT-4: Prevent constructors from calling methods that can be overridden |
Bibliography
[ESA 2005] | Rule 62, Do not call nonfinal methods from within a constructor |
[JLS 2015] | Chapter 8, "Classes" |
Rule 81, Do not call non-final methods from within a constructor |
...
...