开发者

ASTParser order of method calls

I'm using ASTParser to parse a java source code in a project . I managed to get the name and the return type of all the methods in the diffrent classes of my java project . I'm now wondering if it's possible to have the order of methods calls whe开发者_StackOverflow中文版n I run the java project .

In fact I haven't read all the documentation for this class which is a bit complicated. Do you know if it handles the order of accessing the methods in the main program. if it's the case can you give me a simple example or give me the guide lines of what I should do. Thanks in advance


This is actually an extremely hard problem to solve.

When you get the AST for a program, you are getting static information about the structure of the program, not dynamic information about the actual execution of the program. In fact, the general problem of "given the source code for this program, what sequence of method calls will it make?" is undecidable, meaning that no algorithm, no matter how clever, can always get the answer to this question correctly.

If you still need this information, you have a few options. First, you could try approximating the series of method calls, ending up with an answer that gives you something close to the true answer but which does not correctly cover all cases. Second, you could try running the program and monitor what functions get called by writing some sort of JVM plugin, perhaps through JVMTI.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜