Dependency map for Java classes and methods

Many tools are available for this, depending on the size of your system. The grandaddy of them all is Structure101, a commercial product.

http://structure101.com

I've used this on some big projects - it's complex but easily the most comprehensive of all the tools I know. It can graph a huge architecture, and lets you untangle some complex stuff. It has a sister product called reStructure101 where you can do what-if scenarios.

A nice competitor is Stan4j. It's nowhere near as complete, but does some stuff better, particularly showing the dependency context at the class level.

http://www.stan4j.com

(I own both products, but have no commercial affiliation with either)

Another way of viewing complex dependencies, particularly at the project level, is a Dependency Structure Matrix (DSM). Although S101 can do a DSM, Lattix has more support - it can handle Spring and Hibernate dependencies:

http://lattix.com/

(I've not used lattix - they make it too hard to evaluate it, which is bizarre because I work on some very big systems)

If your software is fairly small, and you are more interested in the simple class level, then something like Architexa may help you understand the structure better:

http://www.architexa.com/

Finally, if you want to roll your own, you can easily do this with ASM. It even includes a dependency matrix tool which tracks at the package level:

http://asm.ow2.org/doc/tutorial-asm-2.0.html (see down the page for the nify dependency matrix)

Here's the source for it - it's very simple, but clever. It works off bytecodes. http://cvs.forge.objectweb.org/cgi-bin/viewcvs.cgi/asm/asm/examples/dependencies/src/org/objectweb/asm/depend/


You may want to check out JDepend. It was specifically developed to solve the problem you are facing.

Working as a consultant it is very common for me to be thrown in to a huge legacy code base. Typically the first thing I do is run JDepend on it to try to get my bearing on the code base and all of the dependencies.

Good luck.