mebigfatguy / fb-contrib

a FindBugs/SpotBugs plugin for doing static code analysis for java code bases
http://fb-contrib.sf.net
GNU Lesser General Public License v2.1
154 stars 45 forks source link

PCOA_PARTIALLY_CONSTRUCTED_OBJECT_ACCESS False Positive #435

Open fullben opened 1 year ago

fullben commented 1 year ago

The plugin reports Constructor makes call to non-final method when a constructor calls a private method.

Environment

public class SomeClass {

  private final String s;

  public SomeClass(String s) {
    doSomething();
    this.s = s;
  }

  private void doSomething() {
    ...
  }
}

Current Behavior

A bug (Constructor makes call to non-final method) is reported.

Expected Behavior

No bug is reported, as private methods are implicitly final and cannot be overridden, therefore do not pose an issue.

mebigfatguy commented 10 months ago

does doSomething call public methods in the class?