Title: JSONObject#equals method violates the contract of equals · Issue #65 · stleary/JSON-java · GitHub
Open Graph Title: JSONObject#equals method violates the contract of equals · Issue #65 · stleary/JSON-java
X Title: JSONObject#equals method violates the contract of equals · Issue #65 · stleary/JSON-java
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...
Open Graph 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( JS...
X 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( JS...
Opengraph URL: https://github.com/stleary/JSON-java/issues/65
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"JSONObject#equals method violates the contract of equals","articleBody":"The `equals` method of `JSONObject#Null` violates the [“non-nullity”](http://books.google.com/books?id=ka2VUBqHiWkC\u0026pg=PA41) 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`.\n\nTools like the [equals verifier](http://code.google.com/p/equalsverifier/) fault this implementation because of this violation. Also the Java Development Tools in Eclipse complain because this class [implements equals without implementing hashCode](http://eclipsesource.com/blogs/2012/09/04/the-3-things-you-should-know-about-hashcode/).\n\nSince 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.\n","author":{"url":"https://github.com/ralfstx","@type":"Person","name":"ralfstx"},"datePublished":"2012-09-07T09:30:43.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/65/JSON-java/issues/65"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ca7d9135-7626-1fa9-96cc-101a156669a3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A740:2AF61E:1315D07:18D57B1:6A5B0F43 |
| html-safe-nonce | a90fc11074e5b0636f770023eaa8970a309450ca10a20486c4fd01cfe508efe7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNzQwOjJBRjYxRToxMzE1RDA3OjE4RDU3QjE6NkE1QjBGNDMiLCJ2aXNpdG9yX2lkIjoiMzUyMzk0ODkyNTAxODY0MDE5NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 3fefefc248965a883180757288680d728e66f8587059cfbd74fb56719583ea26 |
| hovercard-subject-tag | issue:6709957 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/stleary/JSON-java/65/issue_layout |
| twitter:image | https://opengraph.githubassets.com/32783708bab04fd6308534db432cadd0dd5077f4c6b1968f3efd10eca9455e32/stleary/JSON-java/issues/65 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/32783708bab04fd6308534db432cadd0dd5077f4c6b1968f3efd10eca9455e32/stleary/JSON-java/issues/65 |
| og:image:alt | 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( JS... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ralfstx |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| turbo-cache-control | no-preview |
| go-import | github.com/stleary/JSON-java git https://github.com/stleary/JSON-java.git |
| octolytics-dimension-user_id | 5107558 |
| octolytics-dimension-user_login | stleary |
| octolytics-dimension-repository_id | 1187853 |
| octolytics-dimension-repository_nwo | stleary/JSON-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1187853 |
| octolytics-dimension-repository_network_root_nwo | stleary/JSON-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width