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'm getting the exception below when appling org.openrewrite.java.ReplaceAnnotation to a java record with a @nullable parameter:
Execution failed for task ':rewriteRun'.
> java.lang.RuntimeException: Error while visiting src/main/java/com/desantisernesto/openrewrite/SimpleProject/nullable/RecordNullableParam.java: java.lang.IllegalStateException: Unable to parse annotation from template:
@org.checkerframework.checker.nullness.qual.Nullable
Use JavaTemplate.Builder.doBeforeParseTemplate() to see what stub is being generated and include it in any bug report.
Full log, recipe a record source code in the comments.
Is it a recipe bug? Should I file an issue for it?
Thanks for logging the issue! Adding the additional details from the Slack thread.
Recipe
type: specs.openrewrite.org/v1beta/recipename: com.desantisernesto.ReplaceNullabledisplayName: Replace null annotations with the Checker Framework Equivalentsdescription: Replace null annotations with the Checker Framework Equivalents.recipeList:
- org.openrewrite.java.ReplaceAnnotation:
annotationPatternToReplace: "@jakarta.annotation.Nullable"annotationTemplateToInsert: "@org.checkerframework.checker.nullness.qual.Nullable"
record code:
importjakarta.annotation.Nonnull;
importjakarta.annotation.Nullable;
public record Person(@NonnullStringlastname, @NonnullStringname, @NullableIntegerage) {
publicPerson(Stringlastname, Stringname) {
this(lastname, name, 0);
}
}
exception:
* What went wrong:
Execution failed for task ':rewriteRun'.
> java.lang.RuntimeException: Error while visiting src/main/java/com/desantisernesto/openrewrite/SimpleProject/nullable/RecordNullableParam.java: java.lang.IllegalStateException: Unable to parse annotation from template:
@org.checkerframework.checker.nullness.qual.Nullable
Use JavaTemplate.Builder.doBeforeParseTemplate() to see what stub is being generated and include it in any bug report.
org.openrewrite.java.internal.template.JavaTemplateJavaExtension$1.visitAnnotation(JavaTemplateJavaExtension.java:62)
org.openrewrite.java.internal.template.JavaTemplateJavaExtension$1.visitAnnotation(JavaTemplateJavaExtension.java:55)
org.openrewrite.java.tree.J$Annotation.acceptJava(J.java:233)
org.openrewrite.java.tree.J.accept(J.java:59)
org.openrewrite.TreeVisitor.visit(TreeVisitor.java:250)
org.openrewrite.TreeVisitor.visit(TreeVisitor.java:157)
org.openrewrite.java.JavaTemplate.apply(JavaTemplate.java:115)
org.openrewrite.java.ReplaceAnnotation$ReplaceAnnotationVisitor.visitAnnotation(ReplaceAnnotation.java:95)
org.openrewrite.java.ReplaceAnnotation$ReplaceAnnotationVisitor.visitAnnotation(ReplaceAnnotation.java:79)
org.openrewrite.java.tree.J$Annotation.acceptJava(J.java:233)
org.openrewrite.java.tree.J.accept(J.java:59)
org.openrewrite.TreeVisitor.visit(TreeVisitor.java:250)
org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:320)
org.openrewrite.java.JavaVisitor.lambda$visitVariableDeclarations$24(JavaVisitor.java:946)
org.openrewrite.internal.ListUtils.map(ListUtils.java:177)
org.openrewrite.java.JavaVisitor.visitVariableDeclarations(JavaVisitor.java:946)
Versions
rewrite version 8.38.1
Gradle 8.10.2
Kotlin: 1.9.24
Groovy: 3.0.22
Ant: Apache Ant(TM) version 1.10.14 compiled on August 16 2023
Launcher JVM: 17.0.8 (Azul Systems, Inc. 17.0.8+7-LTS)
Daemon JVM: /Library/Java/JavaVirtualMachines/jdk17.0.8.jdk/Contents/Home (no JDK specified, using current Java home)
OS: Mac OS X 14.7 aarch64
Hi,
I'm getting the exception below when appling
org.openrewrite.java.ReplaceAnnotation
to a java record with a @nullable parameter:Full log, recipe a record source code in the comments.
Is it a recipe bug? Should I file an issue for it?
Slack Message
The text was updated successfully, but these errors were encountered: