I am using the Java Debug Interface API to write the custom programs for debugging the Java applications I write. I am able to add breakpoints to the start of a required method invocation by using the code as:
ReferenceType classRef = vm.classesByName(className).get(0);
Method meth = classRef.methodsByName(methodName).get(0);
BreakpointRequest brF1 = vm.eventRequestManager().createBreakpointRequest(meth.location());
brF1.enable();
However I am unable to make out how to get Location objects for arbitrary locations within the source files.
There are several ways to retrieve a Location
for other locations in a source file.
E. g., Method
has several operations for this:
allLineLocations()
+ 1 overloadlocationsOfLine(int line)
+ several overloadsAlso ReferenceType has operations for this. Just browse for the usage of Location
.