-
Notifications
You must be signed in to change notification settings - Fork 99
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
- Related to Add unit test showing null Methodinvocation type #870, Recipe to check that Kotlin test methods return Unit #871.
What version of OpenRewrite are you using?
current main of this repo = 9803871
OR = 8.68.1 or similar
What is the smallest, simplest way to reproduce the problem?
Add jspecify to test classpath resources:
+ testParserClasspath("org.jspecify:jspecify:1.0.0")Rebuild test type tables:
./gradlew createTestTypeTable
In TestMethodsShouldBeVoidTest add jspecify:
- .classpathFromResources(new InMemoryExecutionContext(), "junit-jupiter-api-5", "junit-jupiter-params-5"))
+ .classpathFromResources(new InMemoryExecutionContext(), "junit-jupiter-api-5", "junit-jupiter-params-5", "jspecify"))And add the following test case:
@Test
void interfaces() {
//language=java
rewriteRun(
java(
"""
import org.jspecify.annotations.Nullable;
public interface Doer {
@Nullable
String getFile(String input);
}
"""
)
);
}Observed
Caused by:
java.lang.NullPointerException
at java.base/java.util.Objects.requireNonNull(Objects.java:233)
at org.openrewrite.java.testing.cleanup.TestMethodsShouldBeVoid$1.visitMethodDeclaration(TestMethodsShouldBeVoid.java:83)
at org.openrewrite.java.testing.cleanup.TestMethodsShouldBeVoid$1.visitMethodDeclaration(TestMethodsShouldBeVoid.java:53)
at org.openrewrite.java.tree.J$MethodDeclaration.acceptJava(J.java:4021)
at org.openrewrite.java.tree.J.accept(J.java:55)
at org.openrewrite.TreeVisitor.visit(TreeVisitor.java:242)
... 57 more
Commentary
I think there are at least two problems:
- one is assuming method body is not null (which might be not true for interfaces)
- the
TEST_ANNOTATION_PATTERNfalse positive againstorg.jspecify.annotations.Nullable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Status
Done