According to the _Java Language Specification_, [§12, §12.5, "Creation of New Class Instances" |http://java.sun.com/docs/books/jls/third_edition/html/execution.html#12.5] \[ [JLS 2005|AA. References#JLS 05]\]: Wiki Markup
Unlike C++, the Java programming language does not specify altered rules for method dispatch during the creation of a new class instance. If methods are invoked that are overridden in subclasses in the object being initialized, then these overriding methods are used, even before the new object is completely initialized.
...
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
...
[ISO/IEC TR 24772:2010http://www.aitcnet.org/isai/] | Inheritance [RIP] ]]></ac:plain-text-body></ac:structured-macro> |
Bibliography
...
[[ESA 2005AA. References#ESA 05] ] | Rule 62: Do not call nonfinal methods from within a constructor | ]]></ac:plain-text-body></ac:structured-macro> | <ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="9481cfa1-b3d1-4676-a980-da4bc6d94c25"><ac:plain-text-body><![CDATA[ |
[[JLS 2005AA. References#JLS 05]] | [Chapter 8, Classeshttp://java.sun.com/docs/books/jls/third_edition/html/classes.html], §12.5 Creation of New Class Instances | ]]></ac:plain-text-body></ac:structured-macro> | <ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="c6e7e9e6-6345-4b23-a620-c6949f5b5d86"><ac:plain-text-body><![CDATA[ |
[ [Rogue 2000AA. References#Rogue 00]] | Rule 81. Do not call non-final methods from within a constructor ]]></ac:plain-text-body></ac:structured-macro> | ||
Secure Coding Guidelines for the Java Programming Language, Version 3.0 | Guideline 4-4. Prevent constructors from calling methods that can be overridden |
...