JDK-8289825 : ThreadReference.stop does not specify error/exception when virtual thread can't throw async exception
  • Type: Bug
  • Component: core-svc
  • Sub-Component: debugger
  • Affected Version: 19
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2022-07-06
  • Updated: 2022-07-09
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 20
20Unresolved
Description
The JDWP ThreadReference/Stop command includes the following in its specification:

"The target VM may not support, or may only provide limited support, for stopping a virtual thread with an asynchronous exception. It may, for example, only support this operation when the virtual thread is suspended at a breakpoint or singlestep event."

but the command does not specify the JDWP error that is returned when the target VM does support the command but a virtual thread cannot be stopped for some reason (state, not suspended, ...).

The com.sun.jdi.ThreadReference.stop API is similar:

"The target VM may not support, or may only provide limited support, for stopping a virtual thread with an asynchronous exception. It may, for example, only support this operation when the virtual thread is suspended at a breakpoint or singlestep event."

but the method doesn't specify the exception thrown when the target VM supports "stop" but the virtual thread is not in the right "state". It may be that IllegalThreadStateException is the appropriate exception to throw.

The spec of this command and method needs to be re-examined to avoid incompatible changes in the future when support for stopping a virtual thread with an asynchronous exception is added.