This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Applying the encapsulate field refactoring in A.f, it does not change the field assignment "f = 10" by setF(10) in the A constructor. Before Refactoring: public class A { private int f; public A() { f = 10; } int m(int x) { return f; } } Resulting Program: public class A { private int f; public A() { f = 10; } int m(int x) { return getF(); } /** * @return the f */ public int getF() { return f; } /** * @param f the f to set */ public void setF(int f) { this.f = f; } }
From sourcemaking.com:
When you are using self-encapsulation you have to be careful about using the setting method in the constructor. Often it is assumed that you use the setting method for changes after the object is created, so you may have different behavior in the setter than you have when initializing.