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

AddOrUpdateAnnotationAttribute unable to handle @Anno(key = ClassB.staticVar) #4897

Open
SiBorea opened this issue Jan 14, 2025 · 0 comments · May be fixed by #4898
Open

AddOrUpdateAnnotationAttribute unable to handle @Anno(key = ClassB.staticVar) #4897

SiBorea opened this issue Jan 14, 2025 · 0 comments · May be fixed by #4898
Assignees
Labels
bug Something isn't working

Comments

@SiBorea
Copy link
Contributor

SiBorea commented Jan 14, 2025

What version of OpenRewrite are you using?

I am using

  • OpenRewrite 8.42.0
  • Mavenplugin 5.47.0

How are you running OpenRewrite?

Unit Test, maven plugin

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

              package com.example;

              public class Const {
                    public static final String PATH = "path";
              }
              import jakarta.ws.rs.Path;
              import com.example.Const;
              
              @Path(value = Const.PATH)
              public class Example {
                  private void methodName() { }
              }
  - org.openrewrite.java.AddOrUpdateAnnotationAttribute:
      annotationType: jakarta.ws.rs.Path
      attributeName: value
      attributeValue: "UnnamedTag"
      addOnly: false
      appendArray: false

What did you expect to see?

No errors.

What did you see instead?

Failed to parse sources or run recipe

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

Caused by: java.lang.ClassCastException: class org.openrewrite.java.tree.J$FieldAccess cannot be cast to class org.openrewrite.java.tree.J$Literal (org.openrewrite.java.tree.J$FieldAccess and org.openrewrite.java.tree.J$Literal are in unnamed module of loader 'app')
	at org.openrewrite.java.AddOrUpdateAnnotationAttribute$1.lambda$visitAnnotation$2(AddOrUpdateAnnotationAttribute.java:189)
	at org.openrewrite.internal.ListUtils.map(ListUtils.java:243)
	at org.openrewrite.internal.ListUtils.map(ListUtils.java:265)
	at org.openrewrite.java.AddOrUpdateAnnotationAttribute$1.visitAnnotation(AddOrUpdateAnnotationAttribute.java:123)
	at org.openrewrite.java.AddOrUpdateAnnotationAttribute$1.visitAnnotation(AddOrUpdateAnnotationAttribute.java:85)
	at org.openrewrite.java.tree.J$Annotation.acceptJava(J.java:233)
	at org.openrewrite.java.tree.J.accept(J.java:59)
	at org.openrewrite.TreeVisitor.visit(TreeVisitor.java:250)
	... 44 more

Are you interested in [contributing a fix to OpenRewrite]

Yes, I am trying to make a fix

@SiBorea SiBorea added the bug Something isn't working label Jan 14, 2025
@SiBorea SiBorea linked a pull request Jan 14, 2025 that will close this issue
3 tasks
@timtebeek timtebeek moved this to Backlog in OpenRewrite Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Backlog
Development

Successfully merging a pull request may close this issue.

1 participant