String className = ((ClassPrepareEvent)
event).referenceType().name();
// set the possible deferred line breakpoints
List<Integer> lineList = deferringLineBreakpoint.get(className);
if (lineList != null) {
ReferenceType classType = ((ClassPrepareEvent)
event).referenceType();
for (Integer line : lineList) {
List<Location> locations = classType.locationsOfLine(line);
if (!locations.isEmpty()) {
Location loc = locations.get(0);
BreakpointRequest breakpointRequest =
jdb.eventRequestManager.
createBreakpointRequest(loc);
breakpointRequest.setSuspendPolicy(
EventRequest.SUSPEND_ALL);
breakpointRequest.enable();
jdb.breakpointRegisterMap.put(
loc.toString(), breakpointRequest);
System.out.println(
String.format("Breakpoint set: " + loc));
}
}
}
// set the possible deferred method breakpoints
List<String> methodStrList = deferringMethodBreakpoint.get(className);
if (methodStrList != null) {
ReferenceType classType = ((ClassPrepareEvent)
event).referenceType();
for (String methodStr : methodStrList) {
String[] params = methodStr.split("|");
// Generate the target argument type string list
String[] argTypeNames;
if (params.length > 1) {
argTypeNames = params[1].split(",");
} else {
argTypeNames = new String[0];
}
// Get all methods of the class
List<Method> methodList = classType.methodsByName(params[0]);
Method matchedMethod = null;
/*
* As the jdb command argument doesn't supply the result
* value type, it's impossible to generate a jni signature
* for the specified method. I just have to search...