This sample program exhibits the behavior I do not understand:
public class Main {
public static String foo(String value) {
return "length: " + value.length();
}
public static void main(String[] args) {
System.out.println(foo(null));
}
}
The runtime behavior of this problem is clear: It throws a NullPointerException. What is not clear, however, is the warning I get from IntelliJ:
Passing 'null' argument to parameter annotated as @NotNull
Main
@Contract(pure = true)
@NotNull
public static String foo(
@NotNull String value
)
The Contract and NotNull annotations are obviously not in my code. I cannot tell which package they are from since IntelliJ does not support "go to declaration" in the warning tooltip, and I cannot use the normal "go to declaration" because, well, the annotations do not exist in the code.
This is a plain new project without any Maven/Gradle build script nor any included libraries, just to rule out any "magic" compile-time plugins that could try to add annotations.
This leaves the possibility that @NotNull adds itself. But how? Does it have some meta-annotations that trigger its own annotation processor which adds them to my code? Sadly I cannot even try to find out because I don't which package they are from.
What exactly is happening here?