openrewrite / openrewrite/rewrite

Parser: not idempotent on annotated varargs

Open
#3,881 7 comments 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

bug java parser
Dominant language
Java
Stars
3.7k
Forks
570
Avg merge
13h 12m
Merged PRs (30d)
261

Description

What version of OpenRewrite are you using?

I am using

  • Maven/Gradle plugin v5.17.1

What is the smallest, simplest way to reproduce the problem?

class ParserError {
    private String method(@NonNull final String @NonNull... args) {
        return "";
    }
}

What is the full stack trace of any errors you encountered?

java.lang.IllegalStateException: ParserError.java is not print idempotent.
(several lines removed)
-    private String method(@NonNull final String @NonNull... args) {
+    private String method(@NonNull final String[] @NonNull... args) {
         return "";
     }
 
  org.openrewrite.Parser.requirePrintEqualsInput(Parser.java:52)

The NonNull is from org.eclipse.jdt.annotations, but that should work for any type annotation which can be applied to arrays and types. When a normal array is used instead of the varargs, the parser doesn't produce an error.

Are you interested in contributing a fix to OpenRewrite?

probably not, I only feel confident in the recipes area, not the parser

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.