Community
Participate
Working Groups
Build 3.3M4 The support for detecting unused private or local constructs does not flag unused local types. e.g. public class X { private class M { // M unused private class Member {} // Member unused private class Member2 extends M { // Member2 unused } } public static void main(String[] args) { class Local {} // Local unused class Local2 { // Local2 unused class LMember {} // used by field ref class LMember2 extends Local2 { // LMember2 unused } LMember m; } int i = 0; } }
Created attachment 56752 [details] Proposed patch With this patch, following diagnoses are emitted: ---------- 1. WARNING in d:\eclipse\workspaces\dev3.3\plugins\Crap\src\X.java (at line 2) private class M { ^ The type X.M is never used locally ---------- 2. WARNING in d:\eclipse\workspaces\dev3.3\plugins\Crap\src\X.java (at line 3) private class Member {} ^^^^^^ The type X.M.Member is never used locally ---------- 3. WARNING in d:\eclipse\workspaces\dev3.3\plugins\Crap\src\X.java (at line 4) private class Member2 extends M { ^^^^^^^ The type X.M.Member2 is never used locally ---------- 4. WARNING in d:\eclipse\workspaces\dev3.3\plugins\Crap\src\X.java (at line 4) private class Member2 extends M { ^^^^^^^ Access to enclosing constructor X.M() is emulated by a synthetic accessor method. Increasing its visibility will improve your performance ---------- 5. WARNING in d:\eclipse\workspaces\dev3.3\plugins\Crap\src\X.java (at line 8) class Local {} ^^^^^ The type Local is never used locally ---------- 6. WARNING in d:\eclipse\workspaces\dev3.3\plugins\Crap\src\X.java (at line 9) class Local2 { ^^^^^^ The type Local2 is never used locally ---------- 7. WARNING in d:\eclipse\workspaces\dev3.3\plugins\Crap\src\X.java (at line 11) class LMember2 extends Local2 { ^^^^^^^^ The type Local2.LMember2 is never used locally ---------- 8. WARNING in d:\eclipse\workspaces\dev3.3\plugins\Crap\src\X.java (at line 13) LMember m; ^ The field Local2.m is never read locally ---------- 9. WARNING in d:\eclipse\workspaces\dev3.3\plugins\Crap\src\X.java (at line 15) int i = 0; ^ The local variable i is never read ----------
Eric - pls challenge the proposed patch
Created attachment 56842 [details] Philippe's patch + tests (modified and added) All tests (modified and new ones) completed OK. No modification to your original patch Eric.
Thanks Eric. Released for 3.3M5. Fixed
CC'ed Martin, in case JDT/UI needs to adjust (quickfix/cleanup?)
Verified for 3.3 M5 using build I20070206-0010