openrewrite / openrewrite/rewrite
🐛 Unbounded wildcard in `JavaTemplate` does not match array types
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 3.7k
- Forks
- 571
- Avg merge
- 13h 12m
- Merged PRs (30d)
- 261
Description
This happens on OpenRewrite 8.28.1
A JavaTemplate string such as #{arg:any(java.util.Map<?,?>)} will not match the argument Map.of("key", new Object[] {1,2,3}) for example.
Workaround
Changing the template string to a raw type will match: #{arg:any(java.util.Map)}.
Refaster recipes generate templates with wildcards so the workaround is hardly viable unless developers manually copy the generated recipes from target to src and modify them accordingly.
Examples
With the accompanying recipe: https://github.com/Philzen/rewrite-TestNG-to-JUnit5/blob/feba2bf03318e2569569d4f71d82efbd467a8c44/src/main/java/org/philzen/oss/GenericsLstIssue.java
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the failure in the linked GenericsLstIssueTest.java tests using the GenericsLstIssue.java recipe and the JavaTemplate example from the report. Trace JavaTemplate matching for Map against an array-valued argument, then add regression coverage showing that the wildcard template matches the reported Map.of case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100