Analyse which classes are used

Discussion in 'Java' started by Rupert Woodman, Dec 15, 2005.

  1. 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
    Rupert Woodman, Dec 15, 2005
    #1
    1. Advertising

  2. Rupert Woodman

    VisionSet Guest

    "Rupert Woodman" <> wrote in message
    news:dnshn4$kdh$...
    ....
    > 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/

    --
    Mike W
    VisionSet, Dec 15, 2005
    #2
    1. Advertising

  3. Rupert Woodman

    J. Verdrengh Guest

    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.

    Jeroen
    J. Verdrengh, Dec 15, 2005
    #3
  4. Rupert Woodman

    Oliver Wong Guest

    "J. Verdrengh" <> wrote in message
    news:43a1c0d7$0$8927$...
    > 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
    Oliver Wong, Dec 15, 2005
    #4
  5. Rupert Woodman

    Guest

    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
    , Dec 16, 2005
    #5
  6. 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


    <> wrote in message
    news:...
    > 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
    >
    Rupert Woodman, Dec 16, 2005
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Troll
    Replies:
    35
    Views:
    2,327
    Troll
    Sep 4, 2003
  2. Dan
    Replies:
    0
    Views:
    350
  3. Johan Holst Nielsen

    Analyse of PDF (or EPS?)

    Johan Holst Nielsen, Nov 20, 2003, in forum: Python
    Replies:
    13
    Views:
    687
    David Boddie
    Nov 25, 2003
  4. Vusi
    Replies:
    5
    Views:
    417
    John Machin
    Jul 4, 2006
  5. novice

    Help analyse [ char *--*++ptr + 3 ]

    novice, Oct 8, 2006, in forum: C Programming
    Replies:
    8
    Views:
    315
    Christopher Benson-Manica
    Oct 9, 2006
Loading...

Share This Page