Is anyone aware of any methodology to try and determine the method and instance variable dependencies that exact for a single method in an object oriented class? For example, if I have the following code:
public class Foo {
private int x;
private int y;
public Foo() {
x = 1;
y = 2;
}
public void doFoo() {
doJaa(x);
x++;
}
private void doJaa(int xVar) {
System.out.println("x is: " + xVar);
}
private void nop() {
System.out.println("Nada!");
}
}
What I was looking to do was to take a method, say method ‘doFoo’ and determine all of its instance variable and method dependencies (I would like to determine these dependencies at build-time). In this case, those dependencies would be ‘int x’, ‘Foo()’ and ‘doJaa(int x)’. There are no dependencies between method ‘nop’ and ‘doJaa’ however. Is there a name for this type of analysis, just so I can search for more information around it? I am aware of the following analysis techniques
- Control flow graph (No use to me)
- Program Dependence graph
- System Dependence graph
1 isn’t much use to me as it’s concerned with control flow. 2 is concerned with control and data dependencies either within a single method or across method boundaries. I have researched this and it isn’t really what I want as it’s too granular. 3 is a follow on from 2 and again is way too granular for what I need.
I know only one tool JDepend: http://www.clarkware.com/software/JDepend.html
But I doubt it works on one method basics. if it does not help you you need to implement your own logic probably using byte-code manipulation (engineering) library.