Community
Participate
Working Groups
Here is a mistake I do too often. Wondering if you will find this case interesting enough to add it to JDT UI. class MyClass { Foo foo; Bar bar; String msg; public MyClass(Foo foo, Bar bar, String msg) { this.foo = foo; this.arg3 = arg3; // more work } I forgot to assign bar to this.bar . This happens in particular when refactoring a class, declaring extra arguments, passing extra arguments and fixing javadoc (till compile errors are gone). Then start running but things still don't work. Then after some debugging, find out the constructor isn't doing its work. With eclipse 3.2 M3 JRE1.5 I don't see any warning inside the constructor. Suggestion: detect this case and report it. Add the yellow warning decoration under the bar variable in the constructor. "Warning: Argument bar is not assigned in constructor"
Typo on arg3, I meant: class MyClass { Foo foo; Bar bar; String msg; public MyClass(Foo foo, Bar bar, String msg) { this.foo = foo; this.msg = msg; // more work }
A common practise to prevent such bugs is to make these fields final. A warning is problematic, since it will inevitably lead to false positives.
You can enable the "Parameter is never read" compiler problem.
Moving to jdt.core to decide.
Comment 3 is the actual feature you are looking for. We could special case constructors though.
Thanks for suggestion in comment 3.