Versions Compared

Key

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

...

  • Returning this from a non-private method
  • Passing this as a parameter to a method belonging to another class
  • Publishing this from the constructor of an object under construction
  • Publishing this such that pieces of code beyond its current scope can obtain its reference
  • Calling a non-final method from a constructor (MET04-J. Ensure that constructors do not call overridable methods)
  • Overriding the finalizer of a non-final class when its construction and obtaining the this reference of a partially constructed instance, when the construction of the object ceases (OBJ04-J. Do not allow partially initialized objects to be accessed). This is a special case of the previous point.

This guideline focuses on the potential consequences of this escaping during object construction including race conditions and improper initialization.

...