You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'll submit a test for this, but we uncovered the following situation when using the apache commons-collection 3->4 upgrade recipe.
We expect that ChangeStaticFieldToMethod will be able to change this:
import java.util.Collections;
class Foo {
final Object o = java.util.Arrays(Collections.EMPTY_LIST);
}
into
import java.util.Lists;
class Foo {
final Object o = java.util.Arrays(Lists.of());
}
However, when we use the recipe (via that composite recipe), we get a ClassCastException here:
Caused by: org.openrewrite.internal.RecipeRunException: java.lang.ClassCastException: class org.openrewrite.java.tree.J$NewArray cannot be cast to class org.openrewrite.java.tree.J$Block (org.openrewrite.java.tree.J$NewArray and org.openrewrite.java.tree.J$Block are in unnamed module of loader 'app')
at org.openrewrite.TreeVisitor.visit(TreeVisitor.java:287)
at org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:317)
[snip]
Caused by: java.lang.ClassCastException: class org.openrewrite.java.tree.J$NewArray cannot be cast to class org.openrewrite.java.tree.J$Block (org.openrewrite.java.tree.J$NewArray and org.openrewrite.java.tree.J$Block are in unnamed module of loader 'app')
at org.openrewrite.java.ChangeStaticFieldToMethod$1.useNewMethod(ChangeStaticFieldToMethod.java:119)
at org.openrewrite.java.ChangeStaticFieldToMethod$1.visitFieldAccess(ChangeStaticFieldToMethod.java:95)
at org.openrewrite.java.ChangeStaticFieldToMethod$1.visitFieldAccess(ChangeStaticFieldToMethod.java:80)
at org.openrewrite.java.tree.J$FieldAccess.acceptJava(J.java:1943)
at org.openrewrite.java.tree.J.accept(J.java:59)
at org.openrewrite.TreeVisitor.visit(TreeVisitor.java:245)
What version of OpenRewrite are you using?
rewrite's main branch
How are you running OpenRewrite?
IDE - running new test in ChangeStaticFieldToMethodTest. I'll push a draft PR soon.
The text was updated successfully, but these errors were encountered:
…4383)
* [4382] Add test showing issue with ChangeStaticFieldToMethod recipe..
and nested code.
#4382
* Check for type returned from JavaTemplate to fix test
* Fix compilation issue
---------
Co-authored-by: Samuel Cox <sacox@paypal.com>
Co-authored-by: Tim te Beek <tim@moderne.io>
I'll submit a test for this, but we uncovered the following situation when using the apache commons-collection 3->4 upgrade recipe.
We expect that
ChangeStaticFieldToMethod
will be able to change this:into
However, when we use the recipe (via that composite recipe), we get a ClassCastException here:
What version of OpenRewrite are you using?
rewrite's main branch
How are you running OpenRewrite?
IDE - running new test in
ChangeStaticFieldToMethodTest
. I'll push a draft PR soon.The text was updated successfully, but these errors were encountered: