...
Using the equivalence operators to compare values of boxed primitives can lead to erroneous comparisons.
Rule | Severity | Likelihood | Detectable | RepairableRemediation Cost | Priority | Level |
|---|---|---|---|---|---|---|
EXP03-J | Low | Likely | Yes | YesMedium | P6P9 | L2 |
Automated Detection
Detection of all uses of the reference equality operators on boxed primitive objects is straightforward. Determining the correctness of such uses is infeasible in the general case.
Tool | Version | Checker | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| CodeSonar |
| JAVA.COMPARE.EMPTYSTR | Comparison to | Empty String (Java)empty string | Instead instead of == (Java) | Array (Java)Array | ||||||
| Coverity | 7.5 | BAD_EQ | Implemented | |||||||||
| Klocwork |
| CMP.OBJ | ||||||||||
| Parasoft Jtest |
| CERT.EXP03.UEIC | Do not use '==' or '!=' to compare objects | |||||||||
| PVS-Studio |
| V6013 | ||||||||||
| SonarQube |
| S1698 | "==" and "!=" should not be used when "equals" is overridden |
Related Guidelines
CWE-595, Comparison of Object References Instead of Object Contents |
...