JDK-4520573 : Object.equals is not well fitted for 'null' comparison
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 1.3.1
  • Priority: P3
  • Status: Closed
  • Resolution: Won't Fix
  • OS: generic
  • CPU: generic
  • Submitted: 2001-10-29
  • Updated: 2021-10-14
  • Resolved: 2001-10-29
Related Reports
Relates :  
Description

Name: nt126004			Date: 10/29/2001


java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)


Object.equals is not easy to use when you compare two
object references that can be null.
I'd rather have a
static boolean equals(Object o1, Object o2)
{
   if (o1 == null) {
       if (o2 == null) {
           return true;
       }
       return o2.equals(o1);
   }
   return o1.equals(o2);
}
in the Object class.
(Review ID: 134567) 
======================================================================

Comments
EVALUATION We will not be adding a static method to Object. -- iag@sfbay 2001-10-29
29-10-2001