Skip to content

Commit f4b72df

Browse files
committed
8282379: [LOOM] vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod011 sometimes fails
Reviewed-by: dholmes, sspitsyn
1 parent 7fd440d commit f4b72df

15 files changed

+115
-23
lines changed

test/hotspot/jtreg/ProblemList-svc-vthread.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ vmTestbase/nsk/jdb/repeat/repeat001/repeat001.java 8300707 generic-all
8282
####
8383
## NSK JDI tests failing with wrapper
8484

85-
vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod011/TestDescription.java 8282379 generic-all
86-
8785
####
8886
## The test expects an NPE to be uncaught, but nsk.share.MainWrapper
8987
## introduces exception handlers.

test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod011.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -209,6 +209,16 @@ private int runIt(String args[], PrintStream out) {
209209
clsType.setValue(fldToExit, vm.mirrorOf(true));
210210

211211
invThr.join(argHandler.getWaitTime()*60000);
212+
if (invThr.isAlive()) {
213+
// The join failed because the invoke never completed.
214+
log.complain("TEST FAILED: invoke never completed");
215+
tot_res = Consts.TEST_FAILED;
216+
// Do a vm.resume() to see if that helps.
217+
vm.resume();
218+
invThr.join(); // let test time out if this fails
219+
return quitDebuggee();
220+
}
221+
212222
log.display("Thread \"" + invThr.getName() + "\" done");
213223

214224
// check threads status after method invocation

test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod011t.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -87,11 +87,15 @@ private int runIt(String args[]) {
8787
static volatile boolean isInvoked = false;
8888

8989
static long dummyMeth(long l) throws InterruptedException {
90+
/*
91+
* WARNING: Since this method is called using INVOKE_SINGLE_THREADED, we need to
92+
* be careful not to do anything that might block on another thread. That includes
93+
* calling Thread.sleep(), which can be a problem for virtual threads.
94+
*/
9095
invokemethod011t.log.display("dummyMeth: going to loop");
9196
isInvoked = true;
9297
while(!doExit) {
9398
l--; l++;
94-
Thread.currentThread().sleep(400);
9599
}
96100
invokemethod011t.log.display("dummyMeth: exiting");
97101
isInvoked = false;

test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod012.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -202,6 +202,15 @@ private int runIt(String args[], PrintStream out) {
202202

203203
clsType.setValue(fldToExit, vm.mirrorOf(true));
204204
invThr.join(argHandler.getWaitTime()*60000);
205+
if (invThr.isAlive()) {
206+
// The join failed because the invoke never completed.
207+
log.complain("TEST FAILED: invoke never completed");
208+
tot_res = Consts.TEST_FAILED;
209+
// Do a vm.resume() to see if that helps.
210+
vm.resume();
211+
invThr.join(); // let test time out if this fails
212+
return quitDebuggee();
213+
}
205214
log.display("Thread \"" + invThr.getName() + "\" done");
206215

207216
// check threads status after the method invocation

test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod012t.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -89,11 +89,15 @@ private int runIt(String args[]) {
8989
static volatile boolean isInvoked = false;
9090

9191
static long dummyMeth(long l) throws InterruptedException {
92+
/*
93+
* WARNING: Since this method is called using INVOKE_SINGLE_THREADED, we need to
94+
* be careful not to do anything that might block on another thread. That includes
95+
* calling Thread.sleep(), which can be a problem for virtual threads.
96+
*/
9297
invokemethod012t.log.display("dummyMeth: going to loop");
9398
isInvoked = true;
9499
while(!doExit) {
95100
l--; l++;
96-
Thread.currentThread().sleep(400);
97101
}
98102
invokemethod012t.log.display("dummyMeth: exiting");
99103
isInvoked = false;

test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod013.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -204,6 +204,15 @@ private int runIt(String args[], PrintStream out) {
204204
// finish the invocation
205205
clsRef.setValue(fldToExit, vm.mirrorOf(true));
206206
invThr.join(argHandler.getWaitTime()*60000);
207+
if (invThr.isAlive()) {
208+
// The join failed because the invoke never completed.
209+
log.complain("TEST FAILED: invoke never completed");
210+
tot_res = Consts.TEST_FAILED;
211+
// Do a vm.resume() to see if that helps.
212+
vm.resume();
213+
invThr.join(); // let test time out if this fails
214+
return quitDebuggee();
215+
}
207216
log.display("Thread \"" + invThr.getName() + "\" done");
208217

209218
// check threads status after the method invocation

test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod013t.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -88,11 +88,15 @@ private int runIt(String args[]) {
8888
static volatile boolean isInvoked = false;
8989

9090
static long dummyMeth(long l) throws InterruptedException {
91+
/*
92+
* WARNING: Since this method is called using INVOKE_SINGLE_THREADED, we need to
93+
* be careful not to do anything that might block on another thread. That includes
94+
* calling Thread.sleep(), which can be a problem for virtual threads.
95+
*/
9196
invokemethod013t.log.display("dummyMeth: going to loop");
9297
isInvoked = true;
9398
while(!doExit) {
9499
l--; l++;
95-
Thread.currentThread().sleep(400);
96100
}
97101
invokemethod013t.log.display("dummyMeth: exiting");
98102
isInvoked = false;

test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod010.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -206,6 +206,16 @@ private int runIt(String args[], PrintStream out) {
206206
objRef.setValue(fldToExit, vm.mirrorOf(true));
207207

208208
invThr.join(argHandler.getWaitTime()*60000);
209+
if (invThr.isAlive()) {
210+
// The join failed because the invoke never completed.
211+
log.complain("TEST FAILED: invoke never completed");
212+
tot_res = Consts.TEST_FAILED;
213+
// Do a vm.resume() to see if that helps.
214+
vm.resume();
215+
invThr.join(); // let test time out if this fails
216+
return quitDebuggee();
217+
}
218+
209219
log.display("Thread \"" + invThr.getName() + "\" done");
210220

211221
// check threads status after method invocation

test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod010t.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -181,11 +181,15 @@ class invokemethod010tDummyClass {
181181
volatile boolean isInvoked = false;
182182

183183
long longMeth(long l) throws InterruptedException {
184+
/*
185+
* WARNING: Since this method is called using INVOKE_SINGLE_THREADED, we need to
186+
* be careful not to do anything that might block on another thread. That includes
187+
* calling Thread.sleep(), which can be a problem for virtual threads.
188+
*/
184189
invokemethod010t.log.display("invokemethod010tDummyClass: longMeth: going to loop");
185190
isInvoked = true;
186191
while(!doExit) {
187192
l--; l++;
188-
Thread.currentThread().sleep(400);
189193
}
190194
invokemethod010t.log.display("invokemethod010tDummyClass: longMeth: exiting");
191195
isInvoked = false;

test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod011.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -206,6 +206,16 @@ private int runIt(String args[], PrintStream out) {
206206
objRef.setValue(fldToExit, vm.mirrorOf(true));
207207

208208
invThr.join(argHandler.getWaitTime()*60000);
209+
if (invThr.isAlive()) {
210+
// The join failed because the invoke never completed.
211+
log.complain("TEST FAILED: invoke never completed");
212+
tot_res = Consts.TEST_FAILED;
213+
// Do a vm.resume() to see if that helps.
214+
vm.resume();
215+
invThr.join(); // let test time out if this fails
216+
return quitDebuggee();
217+
}
218+
209219
log.display("Thread \"" + invThr.getName() + "\" done");
210220

211221
// check threads status after method invocation

0 commit comments

Comments
 (0)