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 249187 - Method rename refactoring should avoid infinite recursion
Summary: Method rename refactoring should avoid infinite recursion
Status: RESOLVED DUPLICATE of bug 99421
Alias: None
Product: java
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 8.0.2
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Ralph Ruijs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-08 08:39 UTC by ebaumann
Modified: 2015-01-09 09:58 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 ebaumann 2014-12-08 08:39:49 UTC
Rename refactoring can lead to infinite recursion:

public interface A {
    void a();
}

public final class B {

    private void b() {
    }

    private final class Inner implements A {
        @Override
        public void a() {
            b();
        }
    }
}

When renaming A#a() to A#b(), Inner#a() will be renamed to Inner#b(). Now instead of calling B#b(), Inner#b() calls itself and loops infinitely.

Rename refactoring should check non static inner classes for infinite recursion and change method calls to the outer class:

private final class Inner implements A {
    @Override
    public void b() {
        B.this.b();
    }
}

Until that change, it is strongly recommended, to use "Source > Inspect > Single Inspection: Infinite Recursion" after each rename refactoring.
Comment 1 Ralph Ruijs 2015-01-09 09:58:58 UTC

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