RFR: 8361912: ThreadsListHandle::cv_internal_thread_to_JavaThread does not deal with a virtual thread's carrier thread

David Holmes dholmes at openjdk.org
Mon Jul 21 08:32:16 UTC 2025


The `cv_internal_thread_to_JavaThread` method will now check if the thread is a mounted virtual thread, and if so protect the carrier thread. User's of the API that need to deal with virtual threads must still check the carrier themselves as it could change asynchronously, but it is now guaranteed that the carrier JavaThread returned via this method cannot terminate whilst being used (the same as regular platform JavaThreads).

It was noticed whilst updating the documentation that the `JvmtiExport` variant `cv_oop_to_JavaThread` is unused and so can be removed.

Testing:
- tiers 1-4

Thanks

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

Commit messages:
 - Revert to simpler fix without new API
 - Revert "Adapt ThreadSnapshotFactory::get_thread_snapshot to use the new API"
 - Remove unused JvmtiExport::cv_oop_to_JavaThread API
 - Adapt ThreadSnapshotFactory::get_thread_snapshot to use the new API
 - Adapt thread conversion routines to return (and protect) the carrier

Changes: https://git.openjdk.org/jdk/pull/26287/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=26287&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8361912
  Stats: 87 lines in 4 files changed: 19 ins; 54 del; 14 mod
  Patch: https://git.openjdk.org/jdk/pull/26287.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/26287/head:pull/26287

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


More information about the hotspot-dev mailing list