Bug 182430

Summary: [compiler] Improve dead code detection of private methods in cyclic call hierarchy
Product: [Eclipse Project] JDT Reporter: F. H. <lukrez>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3    
Version: 3.3   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description F. H. CLA 2007-04-14 06:13:31 EDT
Two methods, whose visibility modifiers are set to "private" and which are only referred to mutually, should be marked as dead code. See the following example:

public class Test {

    private void foo() {
        bar();
    }
    
    private void bar() {
        foo();
    }
    
    private void foobar() { // The method ... is never used locally
        foobar();
    }
}


The methods foo and bar form a cyclic call hierarchy with two elements, but are not marked as unused private members.  The method foobar forms a cyclic call hierarchy with one element and is correctly detected as dead code.  The unused code detection should of course include cyclic call hierarchies with an arbitrary number of elements and for that case provide an appropriate warning message (because the method is used locally but not reachable).