Back to Intellij Community

ThisEscapedInConstructor

java/java-impl/resources/inspectionDescriptions/ThisEscapedInConstructor.html

2025.3-rc-2402 B
Original Source

Reports possible escapes of this during the object initialization. The escapes occur when this is used as a method argument or an object of assignment in a constructor or initializer. Such escapes may result in subtle bugs, as the object is now available in the context where it is not guaranteed to be initialized.

Example:

class Foo {
    {
      System.out.println(this);
    }
  }