Skip to content

Instantly share code, notes, and snippets.

@emopers
Last active April 1, 2016 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emopers/ad4c0ebef6b782578359 to your computer and use it in GitHub Desktop.
Save emopers/ad4c0ebef6b782578359 to your computer and use it in GitHub Desktop.
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment