8282384: [LOOM] Need test for ThreadReference.interrupt() on a vthread

Reviewed-by: lmesnik, sspitsyn
This commit is contained in:
Chris Plummer
2023-05-01 18:13:11 +00:00
parent c7e1df8328
commit ae5f678fba
2 changed files with 19 additions and 18 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -47,11 +47,9 @@ import java.io.*;
* The test is passed if both 'interrupted status" are equal, <BR>
* otherwise the test failed. <BR>
* <BR>
* The test consists of two cases as follows: <BR>
* The test consists of one test case as follows: <BR>
* - both debuggee's threads are locked up at synchronized block and <BR>
* are not suspended; <BR>
* - both debuggee's threads are locked up at synchronized block and <BR>
* are suspended by java.lang.Thread.suspend() method; <BR>
*/
public class interrupt001 {
@@ -211,7 +209,9 @@ public class interrupt001 {
throw new TestBug("ERROR: Not found ThreadReference for name :" + threadName2);
}
log2("......interrupting the thread2");
log2("......thread2 is " + (thread2.isVirtual() ? "" : "not ") + "a virtual thread");
log2("......interrupting thread2");
thread2.interrupt();
log2("......instructing main thread to check up threads' interrupted statuses");

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -65,9 +65,9 @@ public class interrupt001a {
// scaffold objects
private static volatile ArgumentHandler argumentHandler = null;
private static interrupt001aThread thread2 = null;
private static Thread thread2 = null;
private static interrupt001aThread thread3 = null;
private static Thread thread3 = null;
private static IOPipe pipe;
@@ -102,7 +102,7 @@ public class interrupt001a {
} else if (instruction.equals("newcheck")) {
synchronized (interrupt001aThread.lockingObject) {
synchronized (interrupt001aTask.lockingObject) {
thread2 = threadStart("Thread02");
thread3 = threadStart("Thread03");
@@ -142,14 +142,15 @@ public class interrupt001a {
System.exit(exitCode + PASS_BASE);
}
private static interrupt001aThread threadStart(String threadName) {
interrupt001aThread resultThread = new interrupt001aThread(threadName);
synchronized (resultThread.waitnotifyObj) {
private static Thread threadStart(String threadName) {
interrupt001aTask resultRunnable = new interrupt001aTask(threadName);
Thread resultThread = JDIThreadFactory.newThread(resultRunnable, threadName);
synchronized (resultRunnable.waitnotifyObj) {
resultThread.start();
try {
log1(" before: waitnotifyObj.wait();");
while (!resultThread.ready)
resultThread.waitnotifyObj.wait();
while (!resultRunnable.ready)
resultRunnable.waitnotifyObj.wait();
log1(" after: waitnotifyObj.wait();");
} catch (InterruptedException e) {
logErr("Unexpected InterruptedException while waiting for start of : " + threadName);
@@ -205,10 +206,10 @@ public class interrupt001a {
}
}
class interrupt001aThread extends Thread {
class interrupt001aTask extends NamedTask {
public interrupt001aThread(String threadName) {
super(threadName);
public interrupt001aTask(String taskName) {
super(taskName);
}
public boolean ready;
@@ -235,6 +236,6 @@ class interrupt001aThread extends Thread {
}
void log(String str) {
interrupt001a.log2(Thread.currentThread().getName() + " : " + str);
interrupt001a.log2(getName() + " : " + str);
}
}