2

我正在使用 Java 调试接口 API编写自定义程序来调试我编写的 Java 应用程序。我可以使用以下代码在所需方法调用的开头添加断点:

ReferenceType classRef = vm.classesByName(className).get(0);
Method meth = classRef.methodsByName(methodName).get(0);
BreakpointRequest brF1 = vm.eventRequestManager().createBreakpointRequest(meth.location());
brF1.enable();

但是,我无法弄清楚如何获取源文件中任意位置的 Location 对象。

4

1 回答 1

3

有几种方法可以检索Location源文件中其他位置的 a。

例如,Method为此有几个操作:

  • allLineLocations()+ 1 过载
  • locationsOfLine(int line)+ 几个重载

ReferenceType 也有这方面的操作。只需浏览Location.

于 2012-01-02T13:09:09.197 回答