While it is possible to access static members of a class through an instance of that class, it is a bad practice to do so.
Always access a static member through the declaring class itself, not an instance of the class.
ZoneId.of("Z")
should be replaced with ZoneOffset.UTC
JAVA-W1085Avoid calling ZoneId.of()
to get the UTC timezone offset, and instead use ZoneOffset.UTC
directly.
A boxed primitive is created just to call its compareTo
method. It's more efficient to use the associated static compare method (for double and float since Java 1.4, for other primitive types since Java 7) which works on primitives directly.
Object.equals()
JAVA-W1080Comparing two primitive values with Objects.equals()
can be inefficient, since both primitives will have to be boxed before being compared.
This JavaDoc comment appears to be malformed. Such comments may raise errors or cause crashes when passed to a JavaDoc generation tool.
Rewrite the comment to use correct syntax.
Duration.withNanos()
may not produce correct results JAVA-E1087Using Duration.withNanos()
may produce wrong results, because it will only set the value of the nanoseconds field of
the duration, and will not correctly adjust for any overflow.
This method/constructor has a parameter tag with no description.
Consider adding a description to the tag. If the parameter's name is clear enough, consider removing the parameter tag entirely.
Empty JavaDoc tags are meaningless, and may even cause tools that consume JavaDoc comments to crash.
Always add an explanation when writing JavaDoc tags.
Object.getClass
does not need to be invoked on an instantiated object JAVA-W0077This method allocates an object just to call getClass()
on it, in order to retrieve the Class
object for it. It is simpler to just access the static .class
property of the class itself.
ZoneId.of()
should be passed a valid timezone identifier JAVA-E1092java.time.ZoneId.of()
should not be passed invalid time zone identifier strings, as this will cause exceptions to be thrown at runtime.
A double assignment of a variable to itself has been detected. This may be a typo.
Check whether this is correct and edit it or remove the extra assignment.
readResolve
must return Object
JAVA-E1032readResolve()
must return only java.lang.Object
, not any other type.
serialVersionUID
should be correctly declared JAVA-E1042The serialVersionUID
field must be declared as <access modifier> static final long serialVersionUID
. Not declaring it as such will prevent Java from processing it.
Always terminate calls to assertThat()
or verify()
with a relevant assertion call, such as equals()
, or similar.
This method appears to only call its superclass implementation, while directly passing its parameters to the super method. This method can be removed, as it provides no additional value.
The Java analyzer has detected a narrowing cast of a subtraction in a comparison method that may flip the sign of the result.
equals()
method parameters should not be marked with @NotNull
or equivalent annotations JAVA-W1028Implementations of the equals()
method should not indicate to API consumers that they expect their argument to be non-null.
API consumers should leave null checking to the equals()
implementation.
This method invokes Thread.currentThread()
just to call one of Thread
's static methods.
Most static methods of Thread
operate on the current thread, so there is no need to explicitly get the current thread object to call them.
Private final methods that do not access instance fields should be declared static.
switch
statements with only 2 branches should be if
statements instead JAVA-W1086switch
statements that have only two arms can be better represented as if
statements.