...
VirtualThreads.allThreads() (and JDWP VirtualMachine/AllThreads) enumerates all active live platform threads, virtual threads are not enumerated unless the JDWP agent is started with the includevirtualthreads option (see below).
For thread dumps and troubleshooting purposes the debugger can invoke the com.sun.management.ThreadsHotSpotDiagnosticMXBean.dumpThreads API in the target VM to enumerate threadsgenerate a thread dump. This can be used as stop-gap solution until there is better support in the debugging in the APIs for finding virtual threads in the debugger APIs.
Thread groups
Virtual threads are not active members of a thread group.
JDI ThreadGroupReference::threads (and JDWP ThreadGroupReference/Children) enumerate all active live platform threads in a group, virtual threads are not enumerated.
...
The recommend way is to check if the target VM is version 19 or later. There is no way to determine if --enable-preview was set, but this is also unnecessary. The JDK 19 debug agent will still accept execute commands that are virtual thread specific, even if the JVM was not run with --enable-preview.
...