-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
The equals method of JSONObject#Null violates the “non-nullity” requirement of the equals method in Java. Since null in Java is not an Object, and does not provide an equals method, null.equals( JSONObject.NULL ) cannot return true while JSONObject.NULL.equals( null ) does so. Hence, this equals implementation is not symetric and violates the contract of an equivalence relation. No object must be equal to null.
Tools like the equals verifier fault this implementation because of this violation. Also the Java Development Tools in Eclipse complain because this class implements equals without implementing hashCode.
Since there is only one single instance of JSONObject#NULL, I'd suggest to remove the equals method from JSONObject#Null. Object#equals is a perfect fit for this class.