RFR: 8312498: Thread::getState and JVM TI GetThreadState should return TIMED_WAITING virtual thread is timed parked [v2]

Alan Bateman alanb at openjdk.org
Tue Sep 12 15:02:31 UTC 2023


> Thread::getState is an API for monitoring and management purposes to report the thread state. If a virtual thread is parked with LockSupport.parkNanos, its state is reported as  WAITING when it should be TIMED_WAITING. JVM TI GetThreadState has the same issue in that it returns JVMTI_THREAD_STATE_WAITING_INDEFINITELY instead of the JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT bit set. Not a very visible issue because JDWP maps both states to "WAIT" but it may be noticed by tools using other JVM TI agents.
> 
> The change is straight-forward, it's just additional bit to indicate that the parking/parked/pinned states are timed. The existing virtual/ThreadAPI.java test is expanded to this scenario. A new test is added for JVM TI GetThreadState to test waiting/timed-waited cases (including pinned) as test coverage seems patchy here.

Alan Bateman has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 10 additional commits since the last revision:

 - Merge
 - Remove unecessary RF from test
 - Merge
 - Merge
 - Remove tab
 - Cleanup comments
 - Merge
 - Spurious tab
 - Test improvements
 - Initial commit

-------------

Changes:
  - all: https://git.openjdk.org/jdk/pull/14978/files
  - new: https://git.openjdk.org/jdk/pull/14978/files/872ab6a7..7b9e0d5a

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=14978&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=14978&range=00-01

  Stats: 80726 lines in 2543 files changed: 46386 ins; 17285 del; 17055 mod
  Patch: https://git.openjdk.org/jdk/pull/14978.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14978/head:pull/14978

PR: https://git.openjdk.org/jdk/pull/14978


More information about the core-libs-dev mailing list