/** * Remove the event request list from the vm. If the vm has terminated, do nothing. * @param eventManager * The event request manager. * @param requests * The target event request list. */ public static void deleteEventRequestSafely(EventRequestManager eventManager, List<EventRequest> requests) { try { eventManager.deleteEventRequests(requests); } catch (VMDisconnectedException ex) { // ignore. } }
@Override public void close() throws Exception { try { vm.eventRequestManager().deleteEventRequests(requests()); } catch (VMDisconnectedException ex) { // ignore since removing breakpoints is meaningless when JVM is terminated. } subscriptions().forEach(subscription -> { subscription.dispose(); }); requests.clear(); subscriptions.clear(); }
@Override public void setExceptionBreakpoints(boolean notifyCaught, boolean notifyUncaught) { EventRequestManager manager = vm.eventRequestManager(); ArrayList<ExceptionRequest> legacy = new ArrayList<>(manager.exceptionRequests()); manager.deleteEventRequests(legacy); // When no exception breakpoints are requested, no need to create an empty exception request. if (notifyCaught || notifyUncaught) { // from: https://www.javatips.net/api/REPLmode-master/src/jm/mode/replmode/REPLRunner.java // Calling this seems to set something internally to make the // Eclipse JDI wake up. Without it, an ObjectCollectedException // is thrown on request.enable(). No idea why this works, // but at least exception handling has returned. (Suspect that it may // block until all or at least some threads are available, meaning // that the app has launched and we have legit objects to talk to). vm.allThreads(); // The bug may not have been noticed because the test suite waits for // a thread to be available, and queries it by calling allThreads(). // See org.eclipse.debug.jdi.tests.AbstractJDITest for the example. // get only the uncaught exceptions ExceptionRequest request = manager.createExceptionRequest(null, notifyCaught, notifyUncaught); request.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD); request.enable(); } }
private void consumeRemainingEvents() { while( _eventIterator.hasNext() ) { Event event = _eventIterator.next(); if( event instanceof StepEvent ) { // a pending step event is superceded by a breakpoint or exception event getEventRequestManager().deleteEventRequest( event.request() ); } } // delete any pending step requests getEventRequestManager().deleteEventRequests( getEventRequestManager().stepRequests() ); }