我需要解析某些方法调用调用,包括某些Java类的整个签名,例如Java方法调用解析器?
public class MyClass {
public void myMthod() {
// ... some code here
result = someInstance.someOtherMethod(param1, param2);
// ... some other code here
}
}
因为我想获得类似的结果:
serviceName = someInstance
methodName = someOtherMethod
arguments = {
argument = java.lang.String,
argument = boolean
}
result = java.lang.Long
什么是实现这一目标的最快的方法? 我正在考虑使用RegEx解析器。存在多种发生模式的问题,例如,
a)
result = someInstance.someOtherMethod(getSomething(), param);
b)
result =
getSomeInstance().someOtherMethod(param);
c)
result = getSomeInstance()
.someOtherMethod(
getSomethingElse(), null, param);
任何帮助将非常感激!谢谢!
出于好奇,你的用例是什么? – lhballoti 2010-10-27 13:24:18
我需要做一个静态的源代码分析:我需要找到某个服务类的所有方法调用来做一些接口合约验证。 – Peter 2010-10-27 13:39:57