Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8300575

JVMTI support when using alternative virtual thread implementation



    • Enhancement
    • Status: Resolved
    • P2
    • Resolution: Fixed
    • None
    • 21
    • hotspot
    • b11


      The JVMTI implementation needs to be updated to work with the alternative implementation of virtual threads. At this time, JVMTI is not supported when running with the alternative implementation and --enable-previews (see check in jni_GetEnv). The alternative implementation creates an OS thread for each virtual thread and can be selected by running with -XX:+UnlockExperimentalVMOptions -XX:-VMContinuations. Ports without VM continuations supports, e.g. Zero, use the alternative implementation by default.

      There are several functions that will need to be updated, e.g.

      - StopThread, RunAgentThread, GetCurrentThreadCpuTime, GetThreadCpuTime should return UNSUPPORTED_OPERATION for virtual threads.

      - GetAllThreads and GetAllStackTraces are specified to return only platform threads and so will need to filter out the threads where the Thread object is a BaseVirtualThread.

      - SuspendAllVirtualThreads and ResumeAllVirtualThreads will need to suspend/resume threads where the Thread object is a BaseVirtualThread.

      The JVMTI spec only requires PopFrame, ForceEarlyReturnXXX, SetLocalXXX, GetLocalXXX to work for limited cases with virtual threads. It does not prohibit these functions supporting a wider range of cases so it might that no changes are required here.

      There may be more and searching the JVMTI spec for references to "virtual thread" may identify other functions/events with different behavior specified for virtual threads. Also, if `@requires vm.continuations` is removed from the existing JVMTI tests then they can be run in this mode to find issues.

      As part of this, or as follow-on, we may need test configuration to run some or all of the JVMTI tests with these options to ensure the code is regularly tested.


        Issue Links



              pchilanomate Patricio Chilano Mateo
              alanb Alan Bateman
              0 Vote for this issue
              8 Start watching this issue