提出一种空指针异常自动定位方法。该方法首先结合程序的静态分析技术,利用程序运行时的堆栈信息指导程序切片,然后对得到的切片进行空指针分析及别名分析,得出引发空指针异常的可疑语句集合,最终给出错误定位报告。实验结果表明,所提方法虽然因收集堆栈信息和别名分析增加了时间开销,但是利用堆栈信息可以缩小问题搜索空间,别名分析可以发现隐含的值传递过程,从而克服单独使用静态方法分析结果引起误报和漏报的缺陷,使最终的错误定位结果更精确。
A novel approach to locate the fault for null pointer exception is presented. The approach first computes the static slice guided by the runtime stack, then conducts a null-pointer analysis and aliases analysis on the sliced program and obtains the suspicious statements that throw null-pointer exceptions, and finally generates a fault localization report. The experimental study indicates that, although time spent in runtime stack information collecting and aliases transferring, the proposed approach can narrow the searching space of the problem with runtime stack, and discover the value transfer process with aliases analysis, thereby eliminating false negative and false positive, and improving the effectiveness of fault localization.