JD.CALL.WRONGSTATIC

JD.CALL.WRONGSTATIC appears when a static method is called by means of instance reference.

Vulnerability and risk

Calling of a static method by means of an instance reference is a bad coding practice, and it can cause incorrect behavior. For example, if static method interrupted() is called by means of an instance reference, then the returned state would be the state of the current Thread, not the state of the given instance. If you wants to get the state of the instance, use a non-static call isInterrupted().

Mitigation and prevention

Do not call static methods by means of instance references.

Example 1

Copy
      void run(final Thread thread) throws Throwable{
         thread.interrupted();
     }

JD.CALL.WRONGSTATIC is reported for line 10: Call to static method 'java.lang.Thread.interrupted' via instance reference.