Menu

#1100 ImmutableField: False Negative when one constructor calls another

open
nobody
PMD
3-Major
Bug
4.3
2013-05-31
2013-05-31
No

More of a weakness rather than a bug:

Rule ImmutableField does not recognize that the fields could be immutable in the following code, where one constructor calls another:

public class MyClass
{
  private String a;
  private String b;

  public MyClass(String a)
  {
    this(a, "foo");
  }

  public MyClass(String a, String b)
  {
    this.a = a;
    this.b = b;
  }
}

Discussion


Log in to post a comment.