To get a trial key
fill out the form below
Team License
Enterprise License
* Нажимая на кнопку, вы даете согласие на обработку своих персональных данных.
См. Политику конфиденциальности

Request our prices
New License
License Renewal
--Select currency--
USD
EUR
RUB
* Нажимая на кнопку, вы даете согласие на обработку своих персональных данных.
См. Политику конфиденциальности

Free PVS-Studio license for Microsoft MVP specialists
* Нажимая на кнопку, вы даете согласие на обработку своих персональных данных.
См. Политику конфиденциальности

To get the licence for your open-source project, please fill out this form
* Нажимая на кнопку, вы даете согласие на обработку своих персональных данных.
См. Политику конфиденциальности

I am interested to try it on the platforms:
* Нажимая на кнопку, вы даете согласие на обработку своих персональных данных.
См. Политику конфиденциальности

Message submitted.

Your message has been sent. We will email you at


If you haven't received our response, please do the following:
check your Spam/Junk folder and click the "Not Spam" button for our message.
This way, you won't miss messages from our team in the future.

>
>
>
V6054. Classes should not be compared b…
Analyzer diagnostics
General Analysis (C++)
General Analysis (C#)
General Analysis (Java)
Diagnosis of micro-optimizations (C++)
Diagnosis of 64-bit errors (Viva64, C++)
Customer specific requests (C++)
MISRA errors
AUTOSAR errors
OWASP errors (C#)
Problems related to code analyzer
Additional information
Contents

V6054. Classes should not be compared by their name.

Jul 25 2018

The analyzer has detected class comparison by name. Such comparison is considered incorrect since, as stated by the JVM specification, classes have unique names only inside a package.

In addition to logical errors, such code may sometimes get exposed to various vulnerabilities due to unknown behavior of an untrusted class.

Consider the following example:

if (obj.getClass().getSimpleName().equals("Plane"))
{
  ....
}

This code should be rewritten as follows:

if(obj.getClass().equals(ArrayList.class))
{
  ....
}

or:

if (obj instanceof Plane)
{
  ....
}

or:

if (obj.getClass().isAssignableFrom(Plane.class))
{
  ....
}

This diagnostic is classified as:

Unicorn with delicious cookie
Our website uses cookies to enhance your browsing experience. Would you like to learn more?
Accept