Skip to content

Only run tests for Thread methods removed from newer JDKs on Java 21 and below - #1298

Merged
timtebeek merged 1 commit into
mainfrom
tim/java-25-tests-strategy
Oct 16, 2026
Merged

timtebeek merged 1 commit into
mainfrom
tim/java-25-tests-strategy

Conversation

@timtebeek

Copy link
Copy Markdown
Member

Problem

Running the full test suite on JDK 25 fails four tests. Each one exercises a Thread method that was removed from the JDK after Java 21:

  • ThreadStopUnsupportedTest#replaceResumeWithThrowsOnJava21 (Thread.resume())
  • ThreadStopUnsupportedTest#replaceSuspendWithThrowsOnJava21 (Thread.suspend())
  • DeprecatedCountStackFramesMethodTest, both tests (Thread.countStackFrames())

The parser takes JDK types from the JVM running it, so on JDK 25 these invocations have no method type. Type validation then fails, and the recipes' MethodMatchers don't match.

Changes

Limit these tests to Java 21 and below with @EnabledForJreRange(max = JAVA_21). CI keeps running them, since the build job tests on 21.

This is the last change needed for the whole suite to pass on 25, after #1297 and 353d346 (OptionalStreamRecipe). With it, a full run on JDK 25 gives 2198 tests and 0 failures, using the init script from openrewrite/gh-automation#120. Once that PR is merged, we can add additional_test_java_versions: '[25]' to ci.yml to run the tests on 25 in CI as well.

Follow-up

These tests now pass, but the recipes still silently make no changes when run on JDK 25, for example from a CLI running on 25. The same applies on 21+ to DeleteDeprecatedFinalize, whose test has been limited to Java 17 since we moved to the 21 toolchain. A real fix would match on the method name and receiver type when the method type is missing.

@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Oct 16, 2026
@timtebeek
timtebeek merged commit 7b42869 into main Oct 16, 2026
1 check passed
@timtebeek
timtebeek deleted the tim/java-25-tests-strategy branch October 16, 2026 12:19
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant