openrewrite / openrewrite/rewrite
`InstanceOf.getClazz() is null` in CheckStyle's Java 19+ `InputRecordPatternsPreview`
Open
Nobody has claimed this yet.
bug
java
java 21+
parser
- Dominant language
- Java
- Stars
- 3.7k
- Forks
- 570
- Avg merge
- 13h 12m
- Merged PRs (30d)
- 261
Description
test: https://github.com/checkstyle/checkstyle/pull/16863
line 1:0 token recognition error at: '<u'
line 1:8 token recognition error at: '>'
[ERROR] The recipe produced an error. Please report this to the recipe author.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:01 min
[INFO] Finished at: 2025-04-14T18:06:43+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.openrewrite.maven:rewrite-maven-plugin:6.6.1:run (default-cli) on project checkstyle: Execution default-cli of goal org.openrewrite.maven:rewrite-maven-plugin:6.6.1:run failed: Error while visiting src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/grammar/java19/InputRecordPatternsPreview.java: java.lang.NullPointerException: Cannot invoke "org.openrewrite.java.tree.J.getPrefix()" because the return value of "org.openrewrite.java.tree.J$InstanceOf.getClazz()" is null
[ERROR] org.openrewrite.staticanalysis.OperatorWrap$1.visitInstanceOf(OperatorWrap.java:183)
[ERROR] org.openrewrite.staticanalysis.OperatorWrap$1.visitInstanceOf(OperatorWrap.java:56)
[ERROR] org.openrewrite.java.tree.J$InstanceOf.acceptJava(J.java:2996)
[ERROR] org.openrewrite.java.tree.J.accept(J.java:58)
[ERROR] org.openrewrite.TreeVisitor.visit(TreeVisitor.java:245)
[ERROR] org.openrewrite.staticanalysis.OperatorWrap$1.visit(OperatorWrap.java:70)
[ERROR] org.openrewrite.staticanalysis.OperatorWrap$1.visit(OperatorWrap.java:56)
[ERROR] org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:311)
[ERROR] org.openrewrite.java.JavaVisitor.visitRightPadded(JavaVisitor.java:1382)
[ERROR] org.openrewrite.java.JavaVisitor.visitControlParentheses(JavaVisitor.java:528)
[ERROR] org.openrewrite.java.JavaIsoVisitor.visitControlParentheses(JavaIsoVisitor.java:119)
[ERROR] org.openrewrite.java.JavaIsoVisitor.visitControlParentheses(JavaIsoVisitor.java:30)
[ERROR] org.openrewrite.java.tree.J$ControlParentheses.acceptJava(J.java:5002)
[ERROR] org.openrewrite.java.tree.J.accept(J.java:58)
[ERROR] org.openrewrite.TreeVisitor.visit(TreeVisitor.java:245)
[ERROR] org.openrewrite.staticanalysis.OperatorWrap$1.visit(OperatorWrap.java:70)
[ERROR] ...
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
Process finished with exit code 1
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 with src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/grammar/java19/InputRecordPatternsPreview.java and the stack-traced OperatorWrap.visitInstanceOf method. Reproduce the failure through the rewrite-maven-plugin run, then inspect how the visitor handles this Java 19+ input. Done means the recipe no longer throws the reported NullPointerException for this file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100