What version of OpenRewrite are you using?
I am using
- OpenRewrite v8.79.2
- Maven plugin v6.36.0
How are you running OpenRewrite?
I am using the Maven plugin, and my project is a single module project.
What is the smallest, simplest way to reproduce the problem?
Here the unit test to reproduce the problem:
@Test
void removeTimesOneFromIdentifier() {
rewriteRun(
//language=Java
java(
"""
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import org.mockito.verification.VerificationMode;
class MyTest {
void test(Object myObject, VerificationMode verificationMode) {
myObject.wait();
verify(myObject, verificationMode).wait();
}
void callTest() {
test(new Object(), times(0));
test(new Object(), times(1));
test(new Object(), times(2));
}
}
"""
)
);
}
What did you expect to see?
No error
What did you see instead?
This error: org.openrewrite.java.tree.J$Identifier incompatible with org.openrewrite.java.tree.J$MethodInvocation
What is the full stack trace of any errors you encountered?
java.lang.ClassCastException: class org.openrewrite.java.tree.J$Identifier cannot be cast to class org.openrewrite.java.tree.J$MethodInvocation (org.openrewrite.java.tree.J$Identifier and org.openrewrite.java.tree.J$MethodInvocation are in unnamed module of loader org.codehaus.plexus.classworlds.realm.ClassRealm @4331be30)
org.openrewrite.java.testing.mockito.RemoveTimesZeroAndOne$1.visitMethodInvocation(RemoveTimesZeroAndOne.java:63)
org.openrewrite.java.testing.mockito.RemoveTimesZeroAndOne$1.visitMethodInvocation(RemoveTimesZeroAndOne.java:49)
org.openrewrite.java.tree.J$MethodInvocation.acceptJava(J.java:4281)
org.openrewrite.java.tree.J.accept(J.java:55)
org.openrewrite.TreeVisitor.visit(TreeVisitor.java:242)
org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:309)
org.openrewrite.java.JavaVisitor.visitRightPadded(JavaVisitor.java:1310)
org.openrewrite.java.JavaVisitor.visitMethodInvocation(JavaVisitor.java:870)
org.openrewrite.java.JavaIsoVisitor.visitMethodInvocation(JavaIsoVisitor.java:239)
org.openrewrite.java.testing.mockito.RemoveTimesZeroAndOne$1.visitMethodInvocation(RemoveTimesZeroAndOne.java:52)
org.openrewrite.java.testing.mockito.RemoveTimesZeroAndOne$1.visitMethodInvocation(RemoveTimesZeroAndOne.java:49)
org.openrewrite.java.tree.J$MethodInvocation.acceptJava(J.java:4281)
org.openrewrite.java.tree.J.accept(J.java:55)
org.openrewrite.TreeVisitor.visit(TreeVisitor.java:242)
org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:309)
org.openrewrite.java.JavaVisitor.visitRightPadded(JavaVisitor.java:1310)
What version of OpenRewrite are you using?
I am using
How are you running OpenRewrite?
I am using the Maven plugin, and my project is a single module project.
What is the smallest, simplest way to reproduce the problem?
Here the unit test to reproduce the problem:
What did you expect to see?
No error
What did you see instead?
This error:
org.openrewrite.java.tree.J$Identifier incompatible with org.openrewrite.java.tree.J$MethodInvocationWhat is the full stack trace of any errors you encountered?
Are you interested in contributing a fix to OpenRewrite?