Skip to content

Fail fast on two silent-failure paths in the Java Pattern refactor en… - #161

Merged
RadikalJin merged 1 commit into
mainfrom
java-pattern-fail-fast
Aug 17, 2026
Merged

Fail fast on two silent-failure paths in the Java Pattern refactor en…#161
RadikalJin merged 1 commit into
mainfrom
java-pattern-fail-fast

Conversation

@owoller

@owoller owoller commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

JavaPatternASTOperation could previously produce silently incorrect output in two cases:

  • A @JavaPatternReplacement method body with more than one statement only ever used the first statement; any further statements were discarded with no warning.
  • If more than one @JavaPattern in a matcher file matched the same candidate AST node, JavaPatternASTOperation would attempt to rewrite that node twice against the single shared replacement template, which ASTRewrite is not designed to tolerate.

Both cases now throw a clear exception instead. Added regression tests covering each case, plus a fixed-up CHANGELOG entry.

…gine

JavaPatternASTOperation could previously produce silently incorrect
output in two cases:

- A @JavaPatternReplacement method body with more than one statement
  only ever used the first statement; any further statements were
  discarded with no warning.
- If more than one @JavaPattern in a matcher file matched the same
  candidate AST node, JavaPatternASTOperation would attempt to rewrite
  that node twice against the single shared replacement template,
  which ASTRewrite is not designed to tolerate.

Both cases now throw a clear exception instead. Added regression tests
covering each case, plus a fixed-up CHANGELOG entry.
@owoller
owoller requested a review from RadikalJin August 17, 2026 10:24
@RadikalJin
RadikalJin merged commit f87b2fe into main Aug 17, 2026
2 checks passed
@RadikalJin
RadikalJin deleted the java-pattern-fail-fast branch August 17, 2026 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants