Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Java
Avoid calling non-final methods in a constructor: Applies to static methods too?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Oliver Wong, post: 1583118"] I'm aware of and follow the dogma that one should not call non-final methods in a constructor. However, I'm wondering whether this applies to static methods as well. My understanding of the reasoning behind this rule is that subclasses may see fields in some unstable state, which tells me that the rule need not apply to static methods. However, this code analysis tool is reporting a warning with the following code: <code> public class Test { public Test() { staticMethod(); } public static void staticMethod() { //Does nothing. } } </code> Should I be declaring the staticMethod as being final? Will that even have any effect on the semantics of the code? Or should I rather submit this as a potential bug fix to the tools author? - Oliver [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Java
Avoid calling non-final methods in a constructor: Applies to static methods too?
Top