JD.CAST.UPCAST is triggered when an object is checked with an instance of operator for type A and than cast to type B, where B is a subtype of type A.

Vulnerability and risk

This is usually an error, because the cast is not safe, the object can actually be another subtype of A. In some cases, this error can produce false positives when the path from the instanceof to the cast is incompatible.

Example 1

     void setValue(Object a, Object value) {
         if (a instanceof Map) {
             HashMap b = (HashMap) a;
             b.put(value, "");
         } else if (a instanceof List) {
             List b = (List) a;

JD.CAST.UPCAST: Suspicious cast of 'a' to 'HashMap', where 'HashMap' is a subtype of 'Map'. This object can hold other subtypes of 'Map' which can cause a ClassCastException.-> 15: a instanceof Map-> 16: (HashMap)a