• Post Reply Bookmark Topic Watch Topic
  • New Topic

Tool to display unused classes in a project  RSS feed

 
First Light
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

We have a huge java project with a whole bunch of packages and since a lot of different people worked on it over the last 1,5 years it's full of unnecessary methods,classes and even packages.
Could anybody let me know if there was a tool that displays unnecessary components in a java project?
Thank you.
 
Mark Herschberg
Sheriff
Posts: 6037
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know any specifically designed for this, but some options are
1) Run the JVM with the verbose flag. It will print out each class it loads. Your run would have to put the program through its paces, in order to make sure you exercise each needed class. Even if it's not perfect, it's a good starting point, and can be done at very low cost.
2) IIRC JBuilder has a jar wizard which can supposedly figure out which classes are needed. Other IDEs maye have as well.
3) Most obfuscation tools will look for unused classes and methods. They tend to be prety good (unless reflection or advanced classloading techniques are used). I don't know if they can explicitly tell you what's not needed, you may have to simply obfuscate the code (or maybe run it sans obfuscation) and compare the output jars to the source.

--Mark
hershey@vaultus.com
 
karl koch
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
how about doing a "clean build"
delete all classes, compile just the main class and this should lead to compilation of all used classes since compiler needs to resolve the files. shouldnt it ?
this does not work if you have dynamic class loading with Class.forName and so on.

karl
 
Yuri Gadow
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JProbe Coverage will show you code coverage based on actual use (or rather testing), but given things like reflection and dynamic classloading, it is probably not possible to statically analyze a code base to determine this.
 
sharan basu
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is one more: http://www.optimizeit.com
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!