Community
Participate
Working Groups
When an anonymous inner class implements an interface like java.util.Comparator, it makes little sense to include any public methods that are not in the interface. It is impossible to call them, except from within the inner class itself: new Comparator() { public int compare(Object o1, Object o2) { return 0; } public void uncallableMethod() { // Unused code warning here } }
More background: This warning is useful when refactoring interfaces. Removing methods in an interface can result in a lot of dead code in anonymous classes implementing the interface.
Deferring post 3.1
reopening for consideration within 3.1
Simple generalization of unused private members to all local members.
Can be seen as simple to achieve, and a good polish item. Also other tools like FindBugs support this scenario. Erich: are you supporting this ? I have changes ready for it, trivial change.
Dirk - do you have room for tuning UI for preferences, i.e. change 'unused or unread private member' into 'unused private or local member' ?
This is an easy change as long as we don't add new problem ids.
This is useful and given the changes are trivial I have nothing against adding it now.
Philippe, when support is in please forward the bug to JDT/UI so that I can update the string.
Dirk - entered bug 97284 for UI counterpart.
Released changes to handle local members in same way as private ones. Reworded problem message to read: "The field X.y is never read locally" in place of "The private field X.y is never read locally". No new problem ID. Unused members are still special casing some well-known members for serialization etc... also unused local members recognizes overriding/implementing methods as implicit usage. Adapted test suites which did contain lots of instances of code impacted by this. Added NegativeTest#test440 to demonstrate specific example of it.
*** Bug 96153 has been marked as a duplicate of this bug. ***
Verified in N20050606-0010 + JDT/Core HEAD.
Verified with I20050610-0010