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