Bump library runtime to JDK25 and require JDK24+ to enable virtual threads#501
Bump library runtime to JDK25 and require JDK24+ to enable virtual threads#501
Conversation
Generate changelog in
|
✅ Successfully generated changelog entry!What happened?Your changelog entries have been stored in the database as part of our migration to ChangelogV3. Need to regenerate?Simply interact with the changelog bot comment again to regenerate these entries. |
f9f5e0c to
81ec27a
Compare
| public final class VirtualThreads { | ||
| private static final SafeLogger log = SafeLoggerFactory.get(VirtualThreads.class); | ||
|
|
||
| private static final Optional<VirtualThreadSupport> UNCHECKED_VIRTUAL_THREAD_SUPPORT = maybeInitializeUnchecked(); |
There was a problem hiding this comment.
I was slightly skeptical of using UNCHECKED_VIRTUAL_THREAD_SUPPORT in maybeInitialize but I think this is reasonable. Static variables are initialized in order of declaration in source code ("textual order"). From the language spec
The static initializers and class variable initializers are executed in textual order, and may not refer to class variables declared in the class whose declarations appear textually after the use, even though these class variables are in scope (§8.3.3).
There was a problem hiding this comment.
Another option would be to make this a static field on ReflectiveVirtualThreadSupport instead, to avoid relying on field ordering, which is a bit scary?
(otherwise, please add a comment here explaining that these two fields' ordering must be kept the same)
Before this PR
Users are able to use virtual threads with JDK21 where it was possible for virtual threads to be pinned to platform threads in code using
synchronizedmethods. JEP-491 fixes this. We should require at least Java 24+ to enable virtual threads to ensure their usage is not subject to unwanted thread pinning.After this PR
==COMMIT_MSG==
Bump library runtime to JDK25 and require JDK24+ to enable virtual threads
==COMMIT_MSG==
Possible downsides?
This is a break: we used to allow virtual thread usage on Java 21 and are now changing that behavior. I don't think we should do a major version bump because I expect the impact of this change to be quite minimal in practice.