Commit fa1d3c3
Fix OnlyCatchDeclaredExceptions to skip generic type variables
When a method throws a generic type parameter (e.g., `<TE extends Throwable>`),
the recipe should not attempt to replace the generic catch block. Generic type
variables cannot be used in multi-catch blocks and attempting to do so causes
an IllegalArgumentException during JavaTemplate parsing.
This fix adds a check to skip transformation when any of the thrown exceptions
is a generic type variable, ensuring the recipe only operates on concrete
exception types.
Fixes #715
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>1 parent 21ad269 commit fa1d3c3
File tree
2 files changed
+36
-1
lines changed- src
- main/java/org/openrewrite/staticanalysis
- test/java/org/openrewrite/staticanalysis
2 files changed
+36
-1
lines changedLines changed: 10 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
84 | 93 | | |
85 | 94 | | |
86 | 95 | | |
| |||
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
453 | 453 | | |
454 | 454 | | |
455 | 455 | | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
456 | 482 | | |
0 commit comments