javaintellij-ideacode-inspection

IntelliJ suggests wrong @NotNull annotation


IntelliJ is suggesting to import com.sun.istack.internal.NotNull the @NotNull annotation (which is wrong) in the following program:

public class Test implements Comparable<Test> {
    @Override
    public int compareTo(@NotNull Test o) {
        return 0;
    }
}

When trying the correct import com.intellij.annotations.NotNull (I think) it looks like it can't find the class:

enter image description here


Solution

  • You can Alt+Enter on the warning before you add the annotation, press Right, choose Edit Inspection Settings, then Configure Annotations and specify the annotation you want to be inserted there.