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.
The "Field Can Be Final" transform ignores the comma operator. This makes all fields on the same line final and causes compilation errors. Reason for P2: Inspect and Transform should not add compilation errors. before: public class Example { // Field a can be final private int a, b; public Example(int a, int b) { this.a = a; } public int getA() { return a; } public int getB() { return b; } public void setB(int b) { this.b = b; } } after: public class Example { private final int a, b; public Example(int a, int b) { this.a = a; // ERROR: variable b might not have been initialized } public int getA() { return a; } public int getB() { return b; } public void setB(int b) { // ERROR: cannot assign a value to final variable b this.b = b; } } expected: public class Example { private final int a; private int b; public Example(int a, int b) { this.a = a; } public int getA() { return a; } public int getB() { return b; } public void setB(int b) { this.b = b; } }
The reason is that rewrite tries to be as small as possible. In the case of fields in a field group (common declarator), the "smallest" must be extended to the common fields parent. Fixed hopefully modifier, annotation and type changes for field groups in jet-main#16112f3e2972
Integrated into 'main-silver', will be available in build *201603030002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/16112f3e2972 User: Svata Dedic <sdedic@netbeans.org> Log: #257990: rewrite anywhere in declarator of a variable which is part of variable group will run rewrite on the variable's parent