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

degrade virtual thread support for GetObjectMonitorUsage

XMLWordPrintable

    • b25

      Deprecate GetObjectMonitorUsage and "degrade" the function so that it is specified to only return an owner when the owner is a platform thread. Java 19 re-specified a number of JVMTI functions and events for virtual threads, we missed this one.

      The main motivation for degrading it now is that the object monitor implementation is being updated to allow virtual threads unmount while owning monitors. It would add overhead to record monitor usage when freezing/unmounting, overhead that couldn't be tied to a JVMTI capability as the capability can be enabled at any time.

      GetObjectMonitorUsage was broken for 20+ years (JDK-8247972) without bug reports so it seems unlikely that the function is widely used. Degrading it to only return an owner when the owner is a platform thread has no compatibility impact for tooling that uses it in conjunction with HotSpot thread dumps or ThreadMXBean.

      One other point about GetObjectMonitorUsage is that it pre-dates j.u.concurrent in Java 5 so it can't be used to get a full picture of the lock usage in a program.

      Attached is a patch for the JVMTI spec so that it's clearer what is proposed here.

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

              Created:
              Updated:
              Resolved: