Versions Compared

Key

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

...

Consequently, 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 guideline TSM01-J. Do not let the (this) reference escape during object construction for additional information. As a result, a constructor must not invoke any method that is neither final nor privateconstructors may invoke only methods that are final or private; all other method invocations are forbidden.

Noncompliant Code Example

...