This option controls the addition of the carrier threads' stack trace to the
Throwable.getStackTrace() method. You can add the stack trace of the carrier threads to facilitate the debugging process.
- The platform thread that runs a virtual thread is that virtual thread's carrier thread.
-XX:[+|-]ShowCarrierFramesoption is applicable only if the current thread is a virtual thread.
- If you specify the
-XX:[+|-]ShowCarrierFramesoption has no effect. The
-XX:-StackTraceInThrowableoption removes stack trace of all threads from exceptions.
Virtual threads require platform threads to run because the operating system identifies only platform threads. Therefore, a VM maintains multiple platform threads that are used as carrier threads to run the virtual threads. The VM assigns a virtual thread to a platform thread in a process called mounting.
Although the virtual thread runs on a carrier thread, the stack trace of the virtual thread and its carrier thread are separate. If an exception occurs on running the virtual threads, the thread dumps do not include stack frames from the carrier thread's stack.
You can use the
-XX:+ShowCarrierFrames option to add the stack trace of the carrier thread in addition to the virtual thread stack trace to the
Throwable.getStackTrace() method, if an exception occurs.