@@ -42,24 +42,28 @@ public class Breakpoint implements IBreakpoint {
4242 private String condition = null ;
4343 private String logMessage = null ;
4444 private HashMap <Object , Object > propertyMap = new HashMap <>();
45+ private final boolean suspendAllThreads ;
4546
4647 private boolean async = false ;
4748
48- Breakpoint (VirtualMachine vm , IEventHub eventHub , String className , int lineNumber ) {
49- this (vm , eventHub , className , lineNumber , 0 , null );
49+ Breakpoint (VirtualMachine vm , IEventHub eventHub , String className , int lineNumber , boolean suspendAllThreads ) {
50+ this (vm , eventHub , className , lineNumber , 0 , null , suspendAllThreads );
5051 }
5152
52- Breakpoint (VirtualMachine vm , IEventHub eventHub , String className , int lineNumber , int hitCount ) {
53- this (vm , eventHub , className , lineNumber , hitCount , null );
53+ Breakpoint (VirtualMachine vm , IEventHub eventHub , String className , int lineNumber , int hitCount , boolean suspendAllThreads ) {
54+ this (vm , eventHub , className , lineNumber , hitCount , null , suspendAllThreads );
5455 }
5556
56- Breakpoint (VirtualMachine vm , IEventHub eventHub , String className , int lineNumber , int hitCount , String condition ) {
57- this (vm , eventHub , className , lineNumber , hitCount , condition , null );
57+ Breakpoint (VirtualMachine vm , IEventHub eventHub , String className , int lineNumber , int hitCount ,
58+ String condition , boolean suspendAllThreads ) {
59+ this (vm , eventHub , className , lineNumber , hitCount , condition , null , suspendAllThreads );
5860 }
5961
60- Breakpoint (VirtualMachine vm , IEventHub eventHub , String className , int lineNumber , int hitCount , String condition , String logMessage ) {
62+ Breakpoint (VirtualMachine vm , IEventHub eventHub , String className , int lineNumber , int hitCount ,
63+ String condition , String logMessage , boolean suspendAllThreads ) {
6164 this .vm = vm ;
6265 this .eventHub = eventHub ;
66+ this .suspendAllThreads = suspendAllThreads ;
6367 String contextClass = className ;
6468 String methodName = null ;
6569 String methodSignature = null ;
@@ -79,13 +83,15 @@ public class Breakpoint implements IBreakpoint {
7983 this .logMessage = logMessage ;
8084 }
8185
82- Breakpoint (VirtualMachine vm , IEventHub eventHub , JavaBreakpointLocation sourceLocation , int hitCount , String condition , String logMessage ) {
86+ Breakpoint (VirtualMachine vm , IEventHub eventHub , JavaBreakpointLocation sourceLocation , int hitCount ,
87+ String condition , String logMessage , boolean suspendAllThreads ) {
8388 this .vm = vm ;
8489 this .eventHub = eventHub ;
8590 this .sourceLocation = sourceLocation ;
8691 this .hitCount = hitCount ;
8792 this .condition = condition ;
8893 this .logMessage = logMessage ;
94+ this .suspendAllThreads = suspendAllThreads ;
8995 }
9096
9197 // IDebugResource
@@ -203,6 +209,19 @@ public void setAsync(boolean async) {
203209 this .async = async ;
204210 }
205211
212+ @ Override
213+ public void setSuspendPolicy (String policy ) {
214+ }
215+
216+ @ Override
217+ public String getSuspendPolicy () {
218+ return suspendAllThreads ? "SUSPEND_ALL" : "SUSPEND_EVENT_THREAD" ;
219+ }
220+
221+ protected boolean suspendAllThreads () {
222+ return suspendAllThreads ;
223+ }
224+
206225 @ Override
207226 public CompletableFuture <IBreakpoint > install () {
208227 // It's possible that different class loaders create new class with the same name.
@@ -412,7 +431,11 @@ private CompletableFuture<List<BreakpointRequest>> createBreakpointRequests(List
412431
413432 newLocations .forEach (location -> {
414433 BreakpointRequest request = vm .eventRequestManager ().createBreakpointRequest (location );
415- request .setSuspendPolicy (BreakpointRequest .SUSPEND_EVENT_THREAD );
434+ if ("SUSPEND_ALL" .equals (getSuspendPolicy ())) {
435+ request .setSuspendPolicy (BreakpointRequest .SUSPEND_ALL );
436+ } else {
437+ request .setSuspendPolicy (BreakpointRequest .SUSPEND_EVENT_THREAD );
438+ }
416439 if (hitCount > 0 ) {
417440 request .addCountFilter (hitCount );
418441 }
0 commit comments