force IntelliJ to fail the compilation on NonNull violations

I have the simple code below for testing the NonNull annotations in IntelliJ.

Then I go to:
IntelliJ -> File -> Settings -> Inspections -> Probable bugs -> Constant conditions & exceptions
and I set-up Severity: As error.

Doing so, it marks the line "print(null);" as an error as expected.
However, executing IntelliJ -> Build -> Rebuild project,
it works and it does not show any error and it does not show any warning.

Why is so? Why IntelliJ does not complain when building the project?

How to see a list of the NonNull violations?

Is there a way to enforce IntelliJ to fail the compilation if it finds a NonNull violation?

Note: IntelliJ is set-up to take into account the firebug annotations (as by default);
moreover, using the org.jetbrains.annotations.NotNull produces exactly the same result.


    package test;
    import edu.umd.cs.findbugs.annotations.NonNull;
    public class Hello {
        static public void print(@NonNull Object value) {
            System.out.println("value: " + value.toString());

        static public void main(String[] args) {
            if (args.length > 0) {
            } else {

and the pom.xml file:

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns=""



1 comment
Comment actions Permalink


There's currently no way of forcing IDEA to fail compilation if it finds @NotNull violation. It's because the compiler knows nothing about those annotations, only IDE does. On incremental compilation it would be a problem to detect which files should be re-checked for those violations; even a tiny code change in one file could lead to the whole project re-check. You can write a plugin though that checks the modified files on compilation for such violations.

To see the list of all violations you can run "Constant conditions & exceptions" and "@NotNull/@Nullable problems" inspections on a given scope. The easiest way to do this is to invoke Analyze | Run inspection by name (Ctrl+Alt+Shift+I) and find these inspection names there. Analyze | Inspect code allows for more flexibility in this.

You could also use TeamCity ( to run this inspection remotely on every commit.


Please sign in to leave a comment.