JDK 22 adds support of virtual threads in heap dumps (thread objects/stack traces/stack references):
https://bugs.openjdk.org/browse/JDK-8316691
https://bugs.openjdk.org/browse/JDK-8299426
VisualVM fails to show threads if heap dump contains virtual threads:
- open the heap dump;
- switch to "Threads";
error:
java.lang.NullPointerException
at org.graalvm.visualvm.heapviewer.java.impl.JavaThreadsProvider.getThreadName(JavaThreadsProvider.java:89)
The reason is JavaThreadsProvider expects Thread object has non-null "holder" field.
VirtualThread objects have null "holder" field (virtual threads are always daemon threads, they have fixed priority that cannot be changed, thread status is stored in VirtualThread object).