Analyse which classes are used

R

Rupert Woodman

Hi,

I've inherited a web application which has had a number of developers
working on it over the years and has turned into a bit of an ugly brute.

As I go through and tidy it up before I start the real work of fixing bugs
and adding features, I'm finding that large swathes of code are not used.
If there any tool which anyone is aware of which will take a web application
(i.e. jsp, jspf, java files) and determine which classes are not being used
in any capacity?

I've had a good look and can't find anaything, even commercial apps.

thanks very much
 
V

VisionSet

....
If there any tool which anyone is aware of which will take a web application
(i.e. jsp, jspf, java files) and determine which classes are not being used
in any capacity?

You want to refactor it then!

RefactorIT
Free for upto 50 classes,
30 day evaluate based on the project you attempt to use it with, ie if
RefactorIT sees your app has 301 classes it won't let you use the free
version any more but if you fire off an evaluation request I think you get
the 500 class version for 30 days.
I say this because I've just done the same and got the 100 class version,
and I don't think it will be enough :-(

I've been using it for a couple of years and find it very useful.
I think IDEs such as Netbeans and Eclipse do alot of refactoring stuff that
RefactorIT does, I'll investigate them sometime, but I love my JCreator IDE
too much!

http://www.refactorit.com/
 
O

Oliver Wong

J. Verdrengh said:
Eclipse (http://www.eclipse.org) can retreive all static references to a
class. But dynamic references to a class (eg reflection) won't be detected
by Eclipse.

Unfortunately, AFAIK, there is no button you can click on in Eclipse
that says "Give me a list of all the unused classes", which sounds like what
the OP wants. You might be able to select one class at a time, and say "Give
me all static references to this class", but that won't detect a circular
chain of classes that all refer to each other, and none of them ever gets
"used".

- Oliver
 
R

ricky.clarkson

Use emma [1] to run either your automated tests or interact with your
software while it runs under emma. It will give measures of code
coverage, highlighting unused packages (I think), unused classes,
unused methods and even individual unused lines of code.

A great advantage of this over static analysis is that it isn't fooled
by reflection. A static analysis tool might not pick up that a class
is actually used reflectively.

Also google for java code coverage [2].

[1] http://emma.sourceforge.net/
[2] http://www.google.com/search?q=java code coverage
 
R

Rupert Woodman

Ooops - said thanks in a new thread.... so will say so again in this one!

Thanks for the suggestions chaps - I'll investigate them all.
Obviously a "fix everything" solution would be preferable, but something
which whittled it down to classes to investigate manually, would be more
than acceptable - there never seems to be a magic bullet in this game! :)

Rgds
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top