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 240453

Summary: Rename variable allowed to infrignate on scope
Product: java Reporter: Chiana
Component: RefactoringAssignee: Ralph Ruijs <ralphbenjamin>
Status: RESOLVED DUPLICATE    
Severity: normal    
Priority: P3    
Version: 8.0   
Hardware: PC   
OS: All   
Issue Type: DEFECT Exception Reporter:

Description Chiana 2014-01-14 14:38:50 UTC
[ JDK VERSION : 1.7.0_45 ]

When you rename a variable it is allowed to hide a variable with a larger
scope.
This is not desirable as it can introduce some WERY hard to track errors.

Example;
class Test {
  InputStream input

  Test() {
    InputStream in;
    input=GlobalConnectionBoxHandler.getInputStream();
    in=null;
  }
}

If you in this case (only an example) rename the "in" to "input" it would
destroy the content of "input".

As there is not even a warning I do consider this a BUG rather than an
ENHANCEMENT.
Comment 1 Ralph Ruijs 2014-01-21 10:33:09 UTC
The inline rename in a java-editor is not able to perform these kind of checks. The full rename refactoring already catches these cases. Marking as a duplicate f #215138, as this bug tracks the progress of merging the two.

*** This bug has been marked as a duplicate of bug 215138 ***