OPAL-关于使用CHA算法查找Abstract Class中定义的方法的语法

时间:2017-01-22 14:09:41

标签: opal-framework

这是一个与使用CHA构造Java字节码调用图的算法有关的问题。

由于抽象类中的方法没有具体的方法实现,因此向这些方法添加调用边缘可能会有点误导。 以junit-4.12.jar为例。 runFailed已在junit.runner.BaseTestRunner中定义,这是一个抽象类。此外,方法runFailed中的getTest也会调用junit.runner.BaseTestRunner

在" CHA调用图构建算法的假设层次结构"(Jason& Atanas)中,据说

  

"给定一个调用站点x.m(),其中声明的x类型是C,即   x的可能运行时类型必须是C的非抽象子类型。"

据我所知,如果不在junit.runner.BaseTestRunner getTestjunit.runner.BaseTestRunner runFailed添加呼叫边缘(Calledge1),则从{{1}添加呼叫边缘(Calledge2)更为合理因为TestRunner扩展了BaseTestRunner,所以junit.runner.BaseTestRunner getTest。{/ p>

在运行测试代码以获取CallGraph.calledByStatistics()的结果后,仅找到了Calledge1。 Calledge2不见了。

有没有人可以帮我确认一下? 提前谢谢。

此致

1 个答案:

答案 0 :(得分:1)

我发现OPAL提供了两种调用图视图。第二个不会在调用边缘添加“库调用”边缘。

在CallGraph.calledByStatistics()

绑定在Callsite(PC)和caller.method之间 例如:在“INVOKEVIRTUAL(junit.runner.BaseTestRunner {void runFailed(java.lang.String)})”之间 junit / runner / BaseTestRunner.public junit.framework.Test getTest(java.lang.String)

在CallGraph.callsStatistics()

绑定在subtype.method和caller.method之间 例如: “junit / textui / TestRunner.protected void runFailed(java.lang.String)”和“junit / runner / BaseTestRunner.public junit.framework.Test getTest(java.lang.String)”之间的