Summary: | [quick assist] Move field initializer to constructor | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | RĂ¼diger Herrmann <ruediger.herrmann> |
Component: | UI | Assignee: | JDT-UI-Inbox <jdt-ui-inbox> |
Status: | ASSIGNED --- | QA Contact: | |
Severity: | enhancement | ||
Priority: | P3 | CC: | markus.kell.r, ruediger.herrmann |
Version: | 4.3 | ||
Target Milestone: | --- | ||
Hardware: | All | ||
OS: | All | ||
Whiteboard: |
Description
RĂ¼diger Herrmann
2013-01-29 13:49:49 EST
Moving the initializer is not 100% behavior-preserving in general, because field initializers are executed in declaration order, before the rest of the constructor is executed. To minimize impact, the initialization should be inserted as the first possible statement in all constructors. E.g.: public class Foo { int bar = 1; Foo() { super(); bar++; } } ... becomes: public class Foo { int bar; Foo() { super(); bar = 1; bar++; } } |