This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
is there a tool which will identify unused methods for classes? we have a code base which is probably 3 years old and after much refactoring and such there's most certainly methods that got replaced but never removed.
There are tools to test code coverage - JBuilderX springs to mind. I think its got that sort of profiling capabilities. Nothing however beats a proper manual code review - especially when you got technologies like Reflection where methods might not be directly refered to by other classes, but are used at run time.
There are a number of decent static analysis tools available that will do this -- no need to subject humans to that sort of bookkeeping work. IntelliJ IDEA has this built in, but there's also the open-source PMD.
The Code Guide IDE can do that, as far as I know. You simply tell it all the root classes (main class, classes loaded via reflection etc.), and it flags all unreachable code. Haven't tried it yet, though.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Joined: Jul 11, 2001
Originally posted by Ernest Friedman-Hill: there's also the open-source PMD.
From the description on the homepage it seems as if it only works for private methods, which is rather trivial (Eclipse can do that, too).
Finding unused *public* methods would be helpfull for us, too. Sadly, my feature request has been without effect until now...