runtimeverification / javamop

Runtime verification system for Java, using AspectJ for instrumentation.
http://fsl.cs.illinois.edu/javamop
MIT License
45 stars 37 forks source link

Usefulness of property Comparable_CompareToNull #229

Open emopers opened 8 years ago

emopers commented 8 years ago

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 commented 8 years ago

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