Commit 0eff2d1
committed
Complete Java 24 compatibility fix by backporting UnknownType workaround
This completes the Java 24 compatibility work started in PR #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 #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: #6644
Related: #6725, commit 08b08ab1 parent 07d1ffe commit 0eff2d1
2 files changed
Lines changed: 14 additions & 5 deletions
File tree
- rewrite-java-21/src/main/java/org/openrewrite/java/isolated
Lines changed: 11 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
465 | 465 | | |
466 | 466 | | |
467 | 467 | | |
468 | | - | |
| 468 | + | |
469 | 469 | | |
470 | 470 | | |
471 | 471 | | |
| |||
530 | 530 | | |
531 | 531 | | |
532 | 532 | | |
533 | | - | |
| 533 | + | |
534 | 534 | | |
535 | 535 | | |
536 | 536 | | |
| |||
751 | 751 | | |
752 | 752 | | |
753 | 753 | | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
754 | 762 | | |
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
44 | | - | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
299 | 300 | | |
300 | 301 | | |
301 | 302 | | |
302 | | - | |
| 303 | + | |
303 | 304 | | |
304 | 305 | | |
305 | 306 | | |
| |||
0 commit comments