Sergii Sergii - 3 years ago 71
Java Question

Java. Which @Nullable should I use to mark return value with one?

My java method can return

and non null results. I want mark method with
annotation to make it more readable.

I used
but sonar says Classes from "sun.*" packages should not be used. Code smell Major squid:S1191.

I try to find more similar annotations, but there are variants from different IDE, not from java vendor.

Does java (oracle) provides alternatives for nullable annotation or I should use third party libraries only? If I have to use third party library to have an
which one should be good?

Answer Source

Well, I think for Sonar you could use edu.umd.cs.findbugs.annotations.*, which are deprecated and advise you to use javax.annotation.Nullable.

I mainly use the Jetbrains ones,, but my main goal is the analysis in IntelliJ.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download