Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser: not idempotent on annotated varargs #3881

Open
Bananeweizen opened this issue Jan 3, 2024 · 5 comments · Fixed by #3882
Open

Parser: not idempotent on annotated varargs #3881

Bananeweizen opened this issue Jan 3, 2024 · 5 comments · Fixed by #3882
Assignees
Labels
bug Something isn't working parser-java

Comments

@Bananeweizen
Copy link
Contributor

Bananeweizen commented Jan 3, 2024

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

@Bananeweizen Bananeweizen added the bug Something isn't working label Jan 3, 2024
@timtebeek
Copy link
Contributor

Thanks for reporting this issue here @Bananeweizen ; always good to see your detailed reports. Just yesterday @traceyyoshima merged some changes related to arrays and annotations in #3860 ; Not sure if that also affects varargs, but it might be worth giving the snapshot versions a try. If not we can convert your sample into a unit test in rewrite-java-tck and verify that we're not making any unintended changes.

@traceyyoshima traceyyoshima self-assigned this Jan 3, 2024
@traceyyoshima traceyyoshima moved this to In Progress in OpenRewrite Jan 3, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in OpenRewrite Jan 3, 2024
@knutwannheden knutwannheden reopened this Jan 4, 2024
@github-project-automation github-project-automation bot moved this from Done to In Progress in OpenRewrite Jan 4, 2024
@knutwannheden
Copy link
Contributor

I've reverted the PR and reopened this issue, as we will solve it in a slightly different way. I expect us to complete this next week.

@Laurens-W
Copy link
Contributor

@Laurens-W
Copy link
Contributor

Laurens-W commented Oct 31, 2024

Hey @Bananeweizen may I ask if you can still recall the context of receiving this error?
Were you writing a testcase for a recipe being developed or did you actually run into this while running a recipe on a project?

I've managed to replicate your issue in the above PR and found a solution in the printer that is used to compare before and after states specifically in a test environment!

@Bananeweizen
Copy link
Contributor Author

I'm somewhat certain that I had around 20 such errors while running 1000+ recipes on a large product code base via maven plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working parser-java
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

5 participants