Skip to content

Bump library runtime to JDK25 and require JDK24+ to enable virtual threads#501

Open
mpritham wants to merge 4 commits intodevelopfrom
mpritham/min-25
Open

Bump library runtime to JDK25 and require JDK24+ to enable virtual threads#501
mpritham wants to merge 4 commits intodevelopfrom
mpritham/min-25

Conversation

@mpritham
Copy link

@mpritham mpritham commented Oct 9, 2025

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 synchronized methods. 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.

@changelog-app
Copy link

changelog-app bot commented Oct 9, 2025

Generate changelog in changelog/@unreleased

Type (Select exactly one)

  • Feature (Adding new functionality)
  • Improvement (Improving existing functionality)
  • Fix (Fixing an issue with existing functionality)
  • Break (Creating a new major version by breaking public APIs)
  • Deprecation (Removing functionality in a non-breaking way)
  • Migration (Automatically moving data/functionality to a new system)

Description

Bump library runtime to JDK25 and require JDK24+ to enable virtual threads

Check the box to generate changelog(s)

  • Generate changelog entry

@mpritham mpritham changed the title Require JDK24+ to enable virtual threads Bump library runtime to 25 and require JDK24+ to enable virtual threads Oct 9, 2025
@mpritham mpritham changed the title Bump library runtime to 25 and require JDK24+ to enable virtual threads Bump library runtime to JDK25 and require JDK24+ to enable virtual threads Oct 9, 2025
@changelog-app
Copy link

changelog-app bot commented Oct 9, 2025

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.

public final class VirtualThreads {
private static final SafeLogger log = SafeLoggerFactory.get(VirtualThreads.class);

private static final Optional<VirtualThreadSupport> UNCHECKED_VIRTUAL_THREAD_SUPPORT = maybeInitializeUnchecked();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants