0

要禁用EventReqeustsJDI 内部的所有功能,目前我正在使用:

private void disableRequest(EventRequest request, List < EventRequest > disabled) {
    request.disable();
    disabled.add(request);
}
...
List<EventRequest> requests = new ArrayList<>();
EventRequestManager manager = threadRef.virtualMachine().eventRequestManager();

manager.breakpointRequests().forEach(er - > disableRequest(er, requests));
manager.exceptionRequests().forEach(er - > disableRequest(er, requests));

manager.classUnloadRequests().forEach(er - > disableRequest(er, requests));
manager.classPrepareRequests().forEach(er - > disableRequest(er, requests));

manager.methodEntryRequests().forEach(er - > disableRequest(er, requests));
manager.methodExitRequests().forEach(er - > disableRequest(er, requests));

manager.accessWatchpointRequests().forEach(er - > disableRequest(er, requests));
manager.modificationWatchpointRequests().forEach(er - > disableRequest(er, requests));

manager.threadStartRequests().forEach(er - > disableRequest(er, requests));
manager.threadDeathRequests().forEach(er - > disableRequest(er, requests));

manager.monitorContendedEnteredRequests().forEach(er - > disableRequest(er, requests));
manager.monitorContendedEnterRequests().forEach(er - > disableRequest(er, requests));
manager.monitorWaitedRequests().forEach(er - > disableRequest(er, requests));
manager.monitorWaitRequests().forEach(er - > disableRequest(er, requests));

manager.stepRequests().forEach(er - > disableRequest(er, requests));

这行得通,但是有没有更直接的方法来做到这一点?调用所有这些方法也相当慢......

4

0 回答 0