JDK-6245437 : (spec) Integer.compareTo(null) should document that it throws NPE
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: generic
  • CPU: generic
  • Submitted: 2005-03-24
  • Updated: 2012-03-23
  • Resolved: 2005-03-24
Related Reports
Relates :  
Description
java.lang.Integer.compareTo(null) should throw NPE. It should be described in the javadoc spec.

In fact Integer.compareTo(null) throws null. To reproduce it you may run following test:

public class Test {
    public static void main(String[] args) {
        new Integer(3).compareTo(null);
    }
}

----
the result is:
Exception in thread "main" java.lang.NullPointerException
...


###@###.### 2005-03-24 10:47:23 GMT

Comments
EVALUATION The spec for Comparable already states that implementations should throw a null pointer exception if the argument is null. Noting this behavior should not be expected to be replicated for every Comparable class. Closing as not a bug. ###@###.### 2005-03-24 21:17:42 GMT
24-03-2005