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

Summary: Method rename refactoring should avoid infinite recursion
Product: java Reporter: ebaumann
Component: RefactoringAssignee: Ralph Ruijs <ralphbenjamin>
Status: RESOLVED DUPLICATE    
Severity: normal    
Priority: P3    
Version: 8.0.2   
Hardware: PC   
OS: Windows 7   
Issue Type: DEFECT Exception Reporter:

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 ***