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

Summary: Refactor/rename public member variable
Product: ide Reporter: Adakite
Component: CodeAssignee: issues@ide <issues>
Status: NEW ---    
Severity: normal    
Priority: P3    
Version: 8.2   
Hardware: PC   
OS: Windows 10 x64   
Issue Type: DEFECT Exception Reporter:

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.