Complete Java 24 compatibility fix by backporting UnknownType workaround#6740
Merged
timtebeek merged 1 commit intoopenrewrite:mainfrom Feb 14, 2026
Merged
Conversation
This completes the Java 24 compatibility work started in PR openrewrite#6725 by backporting the isUnknownType() helper method that was removed during the May 2025 simplification (commit 08b08ab). Background: - April 2025: JDK 24 support added with reflection-based workarounds - May 2025: Workarounds removed in "simplification" (commit 08b08ab) - February 2026: DocCommentTable fix backported in PR openrewrite#6725 - This PR: Backports the missing UnknownType fix Problem: Java 24 removed the Type.UnknownType class from javac internals. Direct instanceof Type.UnknownType checks cause NoClassDefFoundError at runtime on Java 24. Solution: Use reflection to check the class name at runtime instead of compile-time instanceof checks. This allows the code to work on both Java 21-23 (where the class exists) and Java 24+ (where it doesn't). Changes: - ReloadableJava21TypeMapping.java: Added isUnknownType() helper, replaced 3 instanceof checks - ReloadableJava21TypeSignatureBuilder.java: Replaced 2 instanceof checks Testing: Verified on spring-petclinic project with Java 24.0.2. Type attribution works correctly, ChangeType and ChangePackage recipes execute successfully, and migrated code compiles without errors. Fixes: openrewrite#6644 Related: openrewrite#6725, commit 08b08ab
timtebeek
approved these changes
Feb 14, 2026
Member
timtebeek
left a comment
There was a problem hiding this comment.
Thanks for the helpful links back to older commits that had introduced the same. Hope this is the final bit we need to restore Gradle 8.x on newer Java versions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background:
Problem:
Java 24 removed the Type.UnknownType class from javac internals. Direct instanceof Type.UnknownType checks cause NoClassDefFoundError at runtime on Java 24.
Solution:
Use reflection to check the class name at runtime instead of compile-time instanceof checks. This allows the code to work on both Java 21-23 (where the class exists) and Java 24+ (where it doesn't).
Changes:
Testing:
Verified on spring-petclinic project with Java 24.0.2. Type attribution works correctly, ChangeType and ChangePackage recipes execute successfully, and migrated code compiles without errors.