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 state bit to indicate that 
park is 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.

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

Commit messages:
 - Remove tab
 - Cleanup comments
 - Merge
 - Spurious tab
 - Test improvements
 - Initial commit

Changes: https://git.openjdk.org/jdk/pull/14978/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14978&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8312498
  Stats: 729 lines in 9 files changed: 647 ins; 41 del; 41 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

Reply via email to