Please use the Apache issue tracking system for new NetBeans issues ( !!
Bug 167376 - [67cat] Quick Fix for "Local variable hides a field" picks wrong identifier to rename
[67cat] Quick Fix for "Local variable hides a field" picks wrong identifier t...
Product: java
Classification: Unclassified
Component: Editor
PC Windows XP
: P3 (vote)
: 6.x
Assigned To: Max Sauer
Depends on:
  Show dependency treegraph
Reported: 2009-06-19 16:02 UTC by swpalmer
Modified: 2009-07-16 17:09 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT


Note You need to log in before you can comment on or make changes to this bug.
Description swpalmer 2009-06-19 16:02:04 UTC
[ BUILD # : 200906142201 ]
[ JDK VERSION : 1.6.* ]

I hit Alt-Enter on a line with a "Local variable hides a field"
warning and selected the only choice, "Rename the field" 

There are two problems

1 - I think this is wrong... the fix should be to "Rename the local
variable" (worst case - give both choices as a possibility)
2 - the editor jumps back in the code to an unrelated field in the
previous function and enters "rename mode"

class A {
 private int value = 0;
 private String somethingElse = "whatever";

 public void hello() {
   somethingElse = "hello";
   System.out.println(somethingElse); // the editor tries to rename

 public void doit() {
   int value = 42; // this is the line that has the warning and is
where I hit Alt-enter

In the above example code that approximates the case in my project, I
will see the idea bulb for "value" in "doit()" and I hit alt-enter,
then select "rename field".  The editor then jumps into the previous
method "hello()" and begins a rename operation on "somethingElse".
Comment 1 swpalmer 2009-06-19 16:07:40 UTC
While I reproduced this *many* times in a row before filing the bug, as soon as I tried again after reporting the bug, it 
worked as expected.  So this may be difficult to reproduce - buit trust me it happened.  I was actually going through a 
file applying many quick-fixes (mostly adding Overrides annotations) and then when I came to this issue it failed in the 
manner described.

Note also that the fix that is applied renames the *local* variable, so the text for the fix "Rename the field" is still 
Comment 2 Max Sauer 2009-06-22 12:33:36 UTC
I've corrected the label. In case the first issue occurs again, please reopen this one with a sample source. Thanks.
Comment 3 Quality Engineering 2009-06-23 07:44:21 UTC
Integrated into 'main-golden', will be available in build *200906230201* on (upload may still be in progress)
User: Max Sauer <>
Log: #167376: Field hidden by local variable label should reflect situation
Comment 4 Petr Blaha 2009-07-02 13:34:23 UTC
Comment 5 pgebauer 2009-07-09 10:35:18 UTC
The fix has been ported into the release67_fixes repository.
Comment 6 Jiri Prox 2009-07-16 17:09:17 UTC
v in 6.7.1

I cannot reproduce the renaming the wrong variable, it it occurs in 6.7.1 again, please file a new issue, thanks

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo