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.

Bug 269004 - Refactor/rename public member variable
Summary: Refactor/rename public member variable
Status: NEW
Alias: None
Product: ide
Classification: Unclassified
Component: Code (show other bugs)
Version: 8.2
Hardware: PC Windows 10 x64
: P3 normal (vote)
Assignee: issues@ide
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-16 13:45 UTC by Adakite
Modified: 2016-11-16 13:45 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adakite 2016-11-16 13:45:11 UTC
When refactoring/renaming a public member variable in Java, references 
to that variable in other classes will insert "Class.this" between the 
object reference and the variable name if the new variable name matches 
a local variable name in the other class. Example when "public int id" 
in ClassB is renamed from "id" to "idnum":

Before refactor:                    After refactor:
|                                   |
| /* ClassA.java */                 | /* ClassA.java */
| public class ClassA {             | public class ClassA {
|   public void methodA() {         |   public void methodA() {
|     ClassB bObj = new ClassB();   |     ClassB bObj = new ClassB();
|     int idnum = 5;                |     int idnum = 5;
|     bObj.id = idnum;              |     bObj.ClassB.this.idnum = idnum;
|   }                               |   }
| }                                 | }
| /* ClassB.java */                 | /* ClassB.java */
| public class ClassB {             | public class ClassB {
|   public int id;                  |   public int idnum;
|   public ClassB() {               |   public ClassB() {
|     this.id = 1;                  |     this.idnum = 1;
|   }                               |   }
| }                                 | }

This issue does not appear to occur when the new variable name does not match a local variable name in another class.