kramer31 said:
Hi. I'm looking for a good static code analysis package for Java. In
particular, the question that I would like to answer is this:
Given a specific line in a aspecific method in a specific class, what
are the possible paths to another specific line in a specific method
in a specific class?
It would be great if the package were free and integrated nicely with
eclipse, but if not, that would be okay.
I doubt there's any static code analysis tool out there that will
satisfactorily answer this question. For starters, for the target line
you've got a reachability problem - if its enclosing method is invoked,
under what conditions will execution involve that target line? This is not
so easy to answer, and a purely static analysis can only tell you what lines
of code will never be reached under any conditions.
Assuming that you've determined that the target line is reachable under
certain conditions, your IDE can help you trace up the calling hierarchy. At
each level I think you'll have to use your judgment which are the profitable
paths to follow. Depending on your IDE you may arrive at some apparent dead
ends doing this, as for example when the JSF layer interposes
itself...although you may have traced up the calling hierarchy to a JSF
action method, it's pretty difficult for an IDE to tell you which prior
methods might be executed before creating that page.
In some cases it might be easier to trace from the other end, but that's a
judgment call again.
Finally, you're presumably talking about minimal length paths, if any.
Because in many apps you'd have an infinite number of paths.
In general the question you're asking depends upon runtime conditions - it's
not something that static code analysis is designed to answer.
AHS