2

I want to know that if there is any easy to use tool, for Java, to perform following operations -

  1. A tool that can tell me what classes are never been called anywhere in the project?
  2. If some classes are calling each other but it is not part of project.
2
  • What do you mean by point 2? I mean, the Pattern class will create a Matcher object upon request (calls the constructor), but isn't commonly used for (most) apps. Your list is likely to end up being too long, if that's what you're looking for. Also, the standard compiler will generate warnings for import references that aren't being 'used' (and methods/variables too, although not necessarily classes). Commented Dec 13, 2011 at 21:35
  • For point 2, let me give you an example. If there are 5 modules in a software and only 4 modules have been used to run application, it means 1 module is never been used. However, in this module there are 3 classes that are calling each other, in this case dependency analysis will tell me that these 3 classes are also been used by other classes. The result of point 1 (in my question) could be 0 classes in this case. Commented Dec 13, 2011 at 21:42

4 Answers 4

2

You can use a static code analyzer such as SourceMonitor. There you can inspect per-method calls and see if a class contains methods that are not called.

Sign up to request clarification or add additional context in comments.

2 Comments

Would it be easy to use for a project that has thousands of classes?
SourceMonitor extracts informations from source code and stores it in convenient way to make it easy to sort, serach, drill-down, etc. If you sort on the "Calls" column then you'll easily find candidate classes. I used it in projects with thousand classes and had no problems.
1

If you are using eclipse you can install the CodePro plugin. It has tools to test code coverage. Instructions here: http://code.google.com/javadevtools/codepro/doc/installation/updatesite_3.5.html

Comments

1

There are tools like Structure 101 and IDEs like Intellij that provide dependencies analysis

Comments

0

UCDetector covers off point 1, not sure about point 2.

http://www.ucdetector.org/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.