Skip to content

Commit a387205

Browse files
committed
8294881: test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose003/TestDescription.java fails
Backport-of: 216c6f63409e60604beb3c4f0e1e0661b1124f8f
1 parent 0a4c423 commit a387205

File tree

5 files changed

+63
-12
lines changed

5 files changed

+63
-12
lines changed

test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose002a.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2022, 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
@@ -133,8 +133,9 @@ public static void main (String argv[]) {
133133
}
134134
break;
135135
} else if (instruction.equals("check_alive")) {
136-
log1("checking on: thread2.isAlive");
137-
if (test_thread.isAlive()) {
136+
log1("checking if thread2 completed");
137+
if (!JDIUtils.waitForCompletion(test_thread)) {
138+
log1("thread2 is alive after vm.dispose().");
138139
pipe.println("alive");
139140
test_thread.interrupt();
140141
} else {

test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose003a.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2022, 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
@@ -135,9 +135,11 @@ public static void main (String argv[]) {
135135
break;
136136
} else if (instruction.equals("check_alive")) {
137137
log1("checking on: thread2.isAlive");
138-
if (test_thread.isAlive()) {
139-
test_thread.resume();
138+
if (!JDIUtils.waitForCompletion(test_thread)) {
140139
pipe.println("alive");
140+
logErr("ERROR thread is alive after vm.dispose()");
141+
exitCode = FAILED;
142+
break;
141143
} else {
142144
pipe.println("not_alive");
143145
}

test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose004a.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2022, 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
@@ -136,9 +136,11 @@ public static void main (String argv[]) {
136136
break;
137137
} else if (instruction.equals("check_alive")) {
138138
log1("checking on: thread2.isAlive");
139-
if (test_thread.isAlive()) {
140-
test_thread.resume();
139+
if (!JDIUtils.waitForCompletion(test_thread)) {
141140
pipe.println("alive");
141+
logErr("ERROR thread is alive after vm.dispose()");
142+
exitCode = FAILED;
143+
break;
142144
} else {
143145
pipe.println("not_alive");
144146
}

test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose005a.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2022, 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
@@ -152,10 +152,12 @@ public static void main (String argv[]) {
152152
logErr("ERROR: unexpected instruction: " + instruction);
153153
exitCode = FAILED;
154154
} else {
155-
log1("checking on: testedThread.isAlive");
155+
log1("checking on: test_thread.done");
156156
if (!test_thread.done) {
157-
test_thread.resume();
158157
pipe.println("alive");
158+
logErr("ERROR test_thread.done is false after vm.dispose()");
159+
exitCode = FAILED;
160+
break;
159161
} else {
160162
pipe.println("not_alive");
161163
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
package nsk.share.jdi;
25+
26+
public class JDIUtils {
27+
28+
/*
29+
* Wait until thread is no longer alive, but only wait
30+
* for a short period of time since it shouldn't take long.
31+
*/
32+
public static boolean waitForCompletion(Thread thread) {
33+
for (int attempt = 1; attempt <= 5; attempt++) {
34+
if (!thread.isAlive()) {
35+
return true;
36+
}
37+
try {
38+
Thread.sleep(attempt * 1000);
39+
} catch (InterruptedException ie) {
40+
}
41+
}
42+
return false;
43+
}
44+
}

0 commit comments

Comments
 (0)