Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usefulness of property Comparable_CompareToNull #229

Open
emopers opened this issue Apr 7, 2016 · 1 comment
Open

Usefulness of property Comparable_CompareToNull #229

emopers opened this issue Apr 7, 2016 · 1 comment

Comments

@emopers
Copy link

emopers commented Apr 7, 2016

Hi, we're rethinking about the usability of the property Comparable_CompareToNull in finding bugs.
As stated in Java API doc, "e.compareTo(null) should throw a NullPointerException even though e.equals(null) returns false.", so intuitively this property would be violated when and only when NullPointerException is thrown by JVM given how this property is written. Though there is possibility that some implementations of Comparable interface may not throw NullPointerException as
required by Java specification, this could be detected by property Comparable_CompareToNullException.
In our samples of this property's violations from monitoring it on 200 open source projects, all violations of this kind are triggered by developers' intentionally passing null in negative tests, which conforms with the argument above. Furthermore, violations of this property do not provide more useful debugging information than the NullPointerException itself.
For now, we cannot think of any conditions that this property can actually help to eliminate bugs in code.

@xiaohe27
Copy link
Contributor

@emopers I agree that the property Comparable_CompareToNull is not useful. The property Comparable_CompareToNullException should suffice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants