8300575: JVMTI support when using alternative virtual thread implementation

Reviewed-by: lmesnik, sspitsyn, alanb
This commit is contained in:
Patricio Chilano Mateo 2023-02-22 15:42:53 +00:00
parent 25bfed3b12
commit 83bea26df4
69 changed files with 558 additions and 121 deletions

View file

@ -2585,10 +2585,8 @@ public class Thread implements Runnable {
StackTraceElement[][] traces = dumpThreads(threads);
Map<Thread, StackTraceElement[]> m = HashMap.newHashMap(threads.length);
for (int i = 0; i < threads.length; i++) {
Thread thread = threads[i];
StackTraceElement[] stackTrace = traces[i];
// BoundVirtualThread objects may be in list returned by the VM
if (!thread.isVirtual() && stackTrace != null) {
if (stackTrace != null) {
m.put(threads[i], stackTrace);
}
// else terminated so we don't put it in the map
@ -2658,11 +2656,7 @@ public class Thread implements Runnable {
* Return an array of all live threads.
*/
static Thread[] getAllThreads() {
Thread[] threads = getThreads();
return Stream.of(threads)
// BoundVirtualThread objects may be in list returned by the VM
.filter(Predicate.not(Thread::isVirtual))
.toArray(Thread[]::new);
return getThreads();
}
private static native StackTraceElement[][] dumpThreads(Thread[] threads);