Bug 318608

Summary: Future request. Warnings if we do not use a public method
Product: [Eclipse Project] JDT Reporter: Lars Svensson <oxvalley>
Component: CoreAssignee: Srikanth Sankaran <srikanth_sankaran>
Status: VERIFIED INVALID QA Contact:
Severity: enhancement    
Priority: P3 CC: amj87.iitr, Olivier_Thomann, srikanth_sankaran
Version: 3.7   
Target Milestone: 3.7 M1   
Hardware: All   
OS: All   
Whiteboard:

Description Lars Svensson CLA 2010-07-01 10:27:46 EDT
Build Identifier: 

I like tidying up my code and use settings like "Unused local or private member". This works great. But why isn't there a similar setting to warn for not used PUBLIC methods and fields??

Reproducible: Always
Comment 1 Srikanth Sankaran CLA 2010-07-02 00:43:28 EDT
The idea behind the warning is that you should be able to
get rid of the complained against item, say by using a
quick fix offered by the IDE, or otherwise by manually.

Given public methods are exposed to the whole wide world,
there could be parts of the code not seen by the compiler
that use the method. This will trigger the warning for most
API methods, where there is no usage "locally" - i.e, the
client code that uses these methods is compiled independently.

See that in cases like what is shown below, the compiler
does produce a warning as appropriate: because the region
of code where such a public method is usable is well bounded
by the language specification, the compiler can and does
verify usage:

public class Tools {    
    private class Private {
    	public void foo() {
    		
    	}
    }
    Private p = new Private();
}

For more general cases, I doubt that anything could be done that
would not also open the flood gates for numerous other pointless
or just plain incorrect warnings.
Comment 2 Olivier Thomann CLA 2010-07-02 10:09:37 EDT
As Srikanth explained, there is nothing we can do for public methods.
Closing as INVALID.
Comment 3 Ayushman Jain CLA 2010-08-03 09:41:08 EDT
Verified for 3.7M1