Community
Participate
Working Groups
One gotcha which people frequently run into is code such as: public class Foo { private String bar; public Foo(String value) { String bar=value; } [other code] } When bar is referred to in other code, it will be null rather than the value passed to the constructor, as the assignment in the constructor is to a local variable. Code with local variables with the same name as instance variables is generally harder to read, with the possible exception of method parameters, eg: public void setValue (String value) { this.value = value; } is commonly idiomatic and should be okay. One other compiler warning related to this, however, would be to flag the assignment in: public void setLongNamedParameter (String longNamesParameter) { this.longNamedParameter = longNamedParameter; } as a no-op - note that the method parameter has a typo in it. (This feature request is similar to 21109.)
The last item was resolved with fix for bug 25092. The original issue remains, will defer post 2.1
Diagnosis for variable hiding got addressed in 3.0 stream.
*** This bug has been marked as a duplicate of 34173 ***