Reputation: 1143
I have wrote a class that implements the comparable interface. I used @NotNull
annotation to suppress the waring in the method parameter. But it still shows a warning.The IDE automatically import this package com.sun.istack.internal.NotNull
for the @NotNull
. Why this is happing? Without using this annotation how to remove this warning ?
I am using Inteij Ultimate with java 8 SE.
Here is my code snippet.
Thank you.
Upvotes: 4
Views: 3877
Reputation: 1796
Apparently, you should be using
public int compareTo(@NonNull Node node) {
instead of
public int compareTo(@NotNull Node node) {
The compiler can determine cases where a code path might receive a null value, without ever having to debug a NullPointerException
.
From here.
For these annotations you need Checker Framework installed. Or you can try what the other answer says.
Upvotes: 5
Reputation: 19821
Change your import, you can use intellij's own com.intellij.annotations.NotNull
, javax.annotation.Nonnull
or javax.validation.constraints.NotNull
.
This is an IntelliJ feature and it was actually possible to configure which nullable/notnull annotation to use, see this guide.
If this doesn't fix it, and the message seems to imply this, try removing the @override
, you are adding an annotation to a parameter that didn't have it in the super class.
Upvotes: 1