Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Invocation of an overridable method during object construction may result in the use of uninitialized data, leading to runtime exceptions or to unanticipated outcomes. Calling overridable methods from constructors can also leak the this reference before object construction is complete, potentially exposing uninitialized or inconsistent data to other threads (see TSM01-J. Do not let the this reference escape during object construction for additional information). As a result, constructors must invoke (directly or indirectly) only methods that are static, final or private.

Noncompliant Code Example

...