JDK-6427291 : (coll) Comparator should mention null parameter
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:collections
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2006-05-18
  • Updated: 2017-05-16
  • Resolved: 2011-05-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7 Other
7 b15Fixed OpenJDK6Fixed
Related Reports
Relates :  
Relates :  
Description
Interfaces Comparable and Comparator have similar methods
compareTo(T o) and compare(T o1, T o2). The spec for method
compareTo says that compareTo(null) should throw NPE,
but is unclear how should behave method compare(...) while one
or both or arguments is null.
Even if the method compare(...) should not throw NPE, its behaviour
in this case should be mentioned in the spec, because it is 
inconsistent with similar compareTo method.

Comments
EVALUATION I agree that the spec for Comparator, Comparable, and the collection classes that use them could be better aligned. In particular, the three Exceptions NullPointerException, ClassCastException, and IllegalArgumentException should be treated consistently.
19-05-2006