Project: JDT
Bug 198689 [Extract Class] Final fields need constructor initialization
Reported: 2007-08-02 11:24:21 | Status: resolved fixed

package p; public class FinalConstructor { private final int test; public FinalConstructor() { test=5; } } Use Extract Class on all fields and create getters and setters. The code results in: package p; public class FinalConstructor { private FinalConstructorParameter parameterObject = new FinalConstructorParameter(); public FinalConstructor() { parameterObject.setTest(5); } } But a final field can only be set in the constructor. I can't see how to solve this problem, except by warning the user.

Files changed in fix:
org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ExtractClassRefactoring.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/IntroduceParameterObjectRefactoring.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ParameterObjectFactory.java