@@ -59,11 +59,23 @@ public static void main(String[] args) {
59
59
60
60
t1 .start ();
61
61
t2 .start ();
62
+
63
+ try {
64
+ // The join ensures that the test completes before we exit main(). If we are using
65
+ // virtual threads, they are always daemon threads, and therefore the JVM will exit
66
+ // while they are still running (and the test has not yet completed). The join
67
+ // isn't really needed for platform threads, since by default they are not
68
+ // daemon threads, but it doesn't hurt any either.
69
+ t1 .join ();
70
+ t2 .join ();
71
+ } catch (InterruptedException e ) {
72
+ throw new RuntimeException (e );
73
+ }
62
74
}
63
75
64
76
// This is called from the debugger via invokeMethod
65
77
public double invokeee () {
66
- System .out .println ("Debuggee: invokeee in thread " + Thread .currentThread ().toString ());
78
+ System .out .println ("Debuggee: invokeee in thread " + Thread .currentThread ().toString ());
67
79
Thread .yield ();
68
80
return longMethod (2 );
69
81
}
@@ -145,9 +157,9 @@ void doInvoke(ThreadReference thread, ObjectReference ref, String methodName) {
145
157
List methods = ref .referenceType ().methodsByName (methodName );
146
158
Method method = (Method ) methods .get (0 );
147
159
try {
148
- System .err .println (" Debugger: Invoking in thread" + thread );
160
+ System .out .println (" Debugger: Invoking in thread " + thread );
149
161
ref .invokeMethod (thread , method , new ArrayList (), ref .INVOKE_NONVIRTUAL );
150
- System .err .println (" Debugger: Invoke done" );
162
+ System .out .println (" Debugger: Invoke done" );
151
163
} catch (Exception ex ) {
152
164
ex .printStackTrace ();
153
165
failure ("failure: Exception" );
@@ -191,7 +203,7 @@ public void breakpointReached(BreakpointEvent event) {
191
203
ThreadReference thread = event .thread ();
192
204
try {
193
205
StackFrame sf = thread .frame (0 );
194
- System .err .println (" Debugger: Breakpoint hit at " + sf .location ());
206
+ System .out .println (" Debugger: Breakpoint hit at " + sf .location ());
195
207
doInvoke (thread , sf .thisObject (), "invokeee" );
196
208
} catch (IncompatibleThreadStateException itsex ) {
197
209
itsex .printStackTrace ();
@@ -214,7 +226,7 @@ protected void runTests() throws Exception {
214
226
targetClass = bpe .location ().declaringType ();
215
227
mainThread = bpe .thread ();
216
228
EventRequestManager erm = vm ().eventRequestManager ();
217
- final Thread mainThread = Thread .currentThread ();
229
+ final Thread mainTestThread = Thread .currentThread ();
218
230
219
231
/*
220
232
* Set event requests
@@ -246,7 +258,7 @@ public void run() {
246
258
vmDisconnected = true ;
247
259
// This awakens the main thread which is
248
260
// waiting for a VMDisconnect.
249
- mainThread .interrupt ();
261
+ mainTestThread .interrupt ();
250
262
break ;
251
263
}
252
264
myBkpts = bkpts ;
0 commit comments