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

make JVMTI thread cpu time functions optional for virtual threads

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 21
    • hotspot
    • None
    • behavioral
    • minimal
    • No compatibility risk as these functions currently do not support virtual threads. The update is to allow other JVMTI implementations to support these functions on virtual threads if they wish.
    • Other
    • SE

      Summary

      Make JVM TI functions GetCurrentThreadCpuTime and GetThreadCpuTime optional for virtual threads.

      Problem

      The following two JVM TI timer functions are currently specified to return JVMTI_ERROR_UNSUPPORTED_OPERATION for virtual threads:

      • GetCurrentThreadCpuTime
      • GetThreadCpuTime

      The support of these two functions must be specified as optional for virtual threads.

      Solution

      Each function spec should have the following description for JVMTI_ERROR_UNSUPPORTED_OPERATION error:

      is a virtual thread and the implementation does not
      support getting the thread CPU time of a virtual thread.

      Specification

      Here is the suggested JVM TI spec patch:

      diff --git a/src/hotspot/share/prims/jvmti.xml b/src/hotspot/share/prims/jvmti.xml
      index 4baaca503c0..5f68fc9a7a9 100644
      --- a/src/hotspot/share/prims/jvmti.xml
      +++ b/src/hotspot/share/prims/jvmti.xml
      @@ -11058,7 +11058,8 @@ myInit() {
             </parameters>
             <errors>
               <error id="JVMTI_ERROR_UNSUPPORTED_OPERATION">
      -          Current thread is a virtual thread.
      +          The current thread is a virtual thread and the implementation does not support
      +          getting the current thread CPU time when the current thread is a virtual thread.
               </error>
             </errors>
           </function>
      @@ -11140,7 +11141,8 @@ myInit() {
             </parameters>
             <errors>
               <error id="JVMTI_ERROR_UNSUPPORTED_OPERATION">
      -          <paramlink id="thread"/> is a virtual thread.
      +          <paramlink id="thread"/> is a virtual thread and the implementation does not
      +          support getting the thread CPU time of a virtual thread.
               </error>
             </errors>
           </function>

            sspitsyn Serguei Spitsyn
            sspitsyn Serguei Spitsyn
            Alan Bateman
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: