You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@ws.apache.org by WJCarpenter <bi...@carpenter.ORG> on 2004/02/29 20:29:00 UTC

MutableBoolean.equals() method?

Maybe not important, but I just stumbled across this. 

The utility class MutableBoolean has a method
"equals(MuteableBoolean)".  (I couldn't find any calls to that method
in the current CVS code.)  I wonder if that method was intended to
override Object.equals rather than overload it with a new signature?
If so, it should be "equals(Object)" and there should also probably be
an override of hashCode().

As the method doesn't seem to be called anywhere, and as the class
doesn't look like it's intended to be used outside Apache SOAP, I'd
suggest just getting rid of it.  Messing with "equals()" is a common
source of confusion and bugs.  Not that it's needed, but trivial patch
below .sig.
-- 
bill@carpenter.ORG (WJCarpenter)    PGP 0x91865119
38 95 1B 69 C9 C6 3D 25    73 46 32 04 69 D6 ED F3


Index: MutableBoolean.java
===================================================================
retrieving revision 1.1
diff -u -r1.1 MutableBoolean.java
--- MutableBoolean.java	4 Oct 2002 19:50:19 -0000	1.1
+++ MutableBoolean.java	29 Feb 2004 19:26:23 -0000
@@ -77,10 +77,6 @@
         this.value = value;
     }
 
-    public boolean equals(MutableBoolean mb) {
-        return this.value == mb.value;
-    }
-
     public String toString() {
         return value ? "true" : "false";
     }


Re: MutableBoolean.equals() method?

Posted by Scott Nichol <sn...@scottnichol.com>.
Hmmm.  You are correct that (1) equals is a frequent source of problems and (2) it is not used in the code.  Since MutableBoolean is used so specifically, dropping equals does seem like a good path to pursue.

Scott Nichol

Do not send e-mail directly to this e-mail address,
because it is filtered to accept only mail from
specific mail lists.
----- Original Message ----- 
From: "WJCarpenter" <bi...@carpenter.ORG>
To: "soap-dev" <so...@ws.apache.org>
Sent: Sunday, February 29, 2004 2:29 PM
Subject: MutableBoolean.equals() method?


Maybe not important, but I just stumbled across this. 

The utility class MutableBoolean has a method
"equals(MuteableBoolean)".  (I couldn't find any calls to that method
in the current CVS code.)  I wonder if that method was intended to
override Object.equals rather than overload it with a new signature?
If so, it should be "equals(Object)" and there should also probably be
an override of hashCode().

As the method doesn't seem to be called anywhere, and as the class
doesn't look like it's intended to be used outside Apache SOAP, I'd
suggest just getting rid of it.  Messing with "equals()" is a common
source of confusion and bugs.  Not that it's needed, but trivial patch
below .sig.
-- 
bill@carpenter.ORG (WJCarpenter)    PGP 0x91865119
38 95 1B 69 C9 C6 3D 25    73 46 32 04 69 D6 ED F3


Index: MutableBoolean.java
===================================================================
retrieving revision 1.1
diff -u -r1.1 MutableBoolean.java
--- MutableBoolean.java 4 Oct 2002 19:50:19 -0000 1.1
+++ MutableBoolean.java 29 Feb 2004 19:26:23 -0000
@@ -77,10 +77,6 @@
         this.value = value;
     }
 
-    public boolean equals(MutableBoolean mb) {
-        return this.value == mb.value;
-    }
-
     public String toString() {
         return value ? "true" : "false";
     }