Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

tool to identify unused methods

 
Mark Lybarger
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic