Back to Intellij Community

SynchronizeOnNonFinalField

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

2025.3-rc-2376 B
Original Source

Reports synchronized statement lock expressions that consist of a non-final field reference. Such statements are unlikely to have useful semantics, as different threads may acquire different locks even when operating on the same object.

Example:

private Object o;
  public void foo() {
    synchronized (o) // synchronization on a non-final field
    { }
  }