ABSTRACT

This function violates the contract that it must compare its parameter with null.

EXPLANATION

The Java standard requires that implementations of Object.equals(), Comparable.compareTo(), and Comparator.compare() must return a specified value if their parameters are null. Failing to follow this contract may result in unexpected behavior.

Example 1: The following implementation of the equals() method does not compare its parameter with null.


public boolean equals(Object object)
{
return (toString().equals(object.toString()));
}

REFERENCES

[1] Standards Mapping - Common Weakness Enumeration - (CWE) CWE ID 398