Static Java Code Analysis

K

kramer31

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.
 
L

Lew

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 don't know if it does path analysis as you ask, but FindBugs is a good
static analysis package for Java.
 
A

Arved Sandstrom

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
 
J

Joshua Cranmer

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?

The best way of doing this would be to generate a call graph and
intersect the subgraphs to contain only the subgraph rooted at the first
method and tailed at the last method.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top