Skip to content

Commit 42f857e

Browse files
authored
fix jdt bug of ObjectCollectedException on ExceptionRequest.enable. (#173)
1 parent 27d64e8 commit 42f857e

File tree

1 file changed

+13
-0
lines changed
  • com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core

1 file changed

+13
-0
lines changed

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/DebugSession.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,19 @@ public void setExceptionBreakpoints(boolean notifyCaught, boolean notifyUncaught
8989
manager.deleteEventRequests(legacy);
9090
// When no exception breakpoints are requested, no need to create an empty exception request.
9191
if (notifyCaught || notifyUncaught) {
92+
// from: https://www.javatips.net/api/REPLmode-master/src/jm/mode/replmode/REPLRunner.java
93+
// Calling this seems to set something internally to make the
94+
// Eclipse JDI wake up. Without it, an ObjectCollectedException
95+
// is thrown on request.enable(). No idea why this works,
96+
// but at least exception handling has returned. (Suspect that it may
97+
// block until all or at least some threads are available, meaning
98+
// that the app has launched and we have legit objects to talk to).
99+
vm.allThreads();
100+
// The bug may not have been noticed because the test suite waits for
101+
// a thread to be available, and queries it by calling allThreads().
102+
// See org.eclipse.debug.jdi.tests.AbstractJDITest for the example.
103+
104+
// get only the uncaught exceptions
92105
ExceptionRequest request = manager.createExceptionRequest(null, notifyCaught, notifyUncaught);
93106
request.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
94107
request.enable();

0 commit comments

Comments
 (0)