3

In Java language. Given a root class, I want to find out all the classes referenced by the root(the whole object graph). Java Reflect is not sufficient. Because :

Class A{
   List list = new ArrayList();

   public void add(Object obj){
      list.add(obj);
   }

   public void add2(){
      Ent ent = new Ent();
      add(ent);
   }
}

Using Reflect, I can easily get "Class A contains (Object)". But actually what I want is “Class A contains (Ent)”.

I want to analyze the java src code or .class file to find out the whole object graph statically, instead of runtime.

Is there anyone can help me ? Thanks!

DON1101
  • 83
  • 3

1 Answers1

1

depfind tools help to track dependencies and take some actions. It can find outbound dependencies.

Showing Only Outbound Dependencies

Outbound dependencies show you who a given programming element depends upon. They are very useful when partitioning programming elements and figuring out what other classes a given class needs in order to run. Dependency Finder uses a textual notation to display them:

programming element
    --> dependable 1
    --> dependable 2
        ...

When there are a lot of dependencies, either because the graph is very big or an element is highly connected, it is useful to filter out the other dependencies so that outbound ones stand out and are easier to read.

http://depfind.sourceforge.net/Manual.html#ShowingOnlyOutboundDependencies

Jayan
  • 18,003
  • 15
  • 89
  • 143
  • @ DON1101 : Good to know it is useful. Please check the question mentioned by nullix. It has more options listed – Jayan Dec 20 '12 at 09:47