JDK-8372410 : ThreadFactory used by Thread.Builder::factory uses non-optimal VarHandle
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2025-11-24
  • Updated: 2025-11-24
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Description
Submitting on behalf of Francesco Nigro:

https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Thread.Builder.OfVirtual.html#name(java.lang.String,long) enable users to create named VirtualThread(s), but the existing code is passing an integer constant type to a VarHandle on a long field, which is sensitive to its signature type and causing it to not be correctly optimized.

Comments
Francesco doesn't have JBS yet so best to assign it to me for now. Note that the issue isn't specific to virtual thread, the VarHandle when computing a thread name forces a conversion with platform threads too.
24-11-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/28475 Date: 2025-11-24 13:05:40 +0000
24-11-2025