Consider this github repository. https://github.com/dfabulich/bazel-checker-framework-bug
It includes a sample X.java
file that flagrantly violates the rules of the @Nonnull
annotation.
import javax.annotation.Nonnull;
public class X {
public static void main(String[] args) {
new X().exec();
}
public void exec() {
System.out.println(this.method());
}
@Nonnull
private String method() {
return null;
}
}
The WORKSPACE
file just includes checker.jar
.
maven_jar(
name="checker",
artifact="org.checkerframework:checker:2.3.1"
)
The BUILD
file invokes the compiler with the checker framework configured as a java_plugin
.
java_library(
name='x',
srcs=['X.java'],
deps=['@checker//jar'],
plugins=['checker'],
)
java_plugin(
name='checker',
deps=['@checker//jar'],
processor_class='org.checkerframework.checker.nullness.NullnessChecker',
)
When I bazel build x
, the build fails with this error:
error: InvocationTargetException when invoking constructor for class org.checkerframework.checker.nullness.KeyForAnnotatedTypeFactory; Underlying cause: java.lang.StackOverflowError; The Checker Framework crashed. Please report the crash. To see the full stack trace invoke the compiler with -AprintErrorStack
When I comment out the plugins
line in the BUILD
file, the build succeeds without error. (That makes sense, but I ultimately want the Checker Framework to fail this build with a return.type.incompatible
error.)
Am I making a mistake here? Is this a bug in Bazel?