Project: JDT
Bug 82005 "Encapsulate Field" changes the data type of member variable [refactoring] [sef]
Reported: 2004-12-29 16:54:30 | Status: resolved fixed

Eclipse Version: Version: 3.1.0 Build id: 200412162000 Create this simple class in eclipse - public class TestEncapsulate { String a, b; } 1) Select the Field a 2) Right-click and select Refactor -> Encapsulate Field. 3) Click Ok. 4) The following code is generated - public class TestEncapsulate { String b; private int a; /** * @param a The a to set. */ void setA(String a) { this.a = a; } /** * @return Returns the a. */ String getA() { return a; } } Problems a) The field was changed to a private field even though it was package-private earlier. b) The data type was changed from String to int!!! The encapsulate field works fine when there is only one field delared in one line (String a;) It breaks in the above code for both fields 'a' & 'b'.

Files changed in fix:
org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/sef/SelfEncapsulateFieldRefactoring.java