How to find dead code

Discussions

General J2EE: How to find dead code

  1. How to find dead code (2 messages)

    There is a lot of tools that tell me that a private method is dead code (Eclipse, by example), but I can't find a tool to tell me a public or protected method is never used. I know it's harder to code, but not that hard ?

    Do anybody know a tool that is able to discover dead code in unused public method, unused classes ?

      Adrien
  2. reflection based method invocation[ Go to top ]

    I know it's harder to code, but not that hard ?

    I think it is not harder to code but simply impossible.
    How do you want to find method invocations done by using reflection?

    Wolfgang
  3. How to find dead code[ Go to top ]

    Many tools do this (though not with 100% reliability, they can't see if you call a method with reflection). However, in order to do their job they must see and analyze ALL your code. This is expensive, so they do it only when you ask for a coverage report.

    If my memory serves me IntelliJ IDEA does it. TogetherJ did it a long time ago, so I assume that JBuilder can do it now. I bet there is a plug-in for Eclipse, but I haven't seen one.

    You can download a trial version of IDEA from http://www.jetbrains.com and try it out.