[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] FYI: Making hashCode consistent with equals in gnu.CORBA
From: |
Meskauskas Audrius |
Subject: |
[cp-patches] FYI: Making hashCode consistent with equals in gnu.CORBA |
Date: |
Wed, 14 Sep 2005 23:09:40 +0200 |
User-agent: |
Mozilla Thunderbird 1.0.2 (Windows/20050317) |
2005-09-14 Audrius Meskauskas <address@hidden>
* gnu/CORBA/Connected_objects.java (equals),
* gnu/CORBA/Poa/activeObjectMap.java (equals): Removed.
* gnu/CORBA/Version.java (hashCode),
* gnu/CORBA/gnuAny.java (hashCode): New method.
Index: gnu/CORBA/Connected_objects.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/CORBA/Connected_objects.java,v
retrieving revision 1.4
diff -u -r1.4 Connected_objects.java
--- gnu/CORBA/Connected_objects.java 22 Jul 2005 16:57:47 -0000 1.4
+++ gnu/CORBA/Connected_objects.java 14 Sep 2005 20:48:04 -0000
@@ -90,17 +90,6 @@
* applicable.
*/
public final java.lang.Object identity;
-
- public boolean equals(java.lang.Object other)
- {
- if (other instanceof cObject)
- {
- cObject o = (cObject) other;
- return o.object.equals(object) && o.port == port;
- }
- else
- return false;
- }
}
/**
Index: gnu/CORBA/Version.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/CORBA/Version.java,v
retrieving revision 1.3
diff -u -r1.3 Version.java
--- gnu/CORBA/Version.java 14 Sep 2005 08:09:44 -0000 1.3
+++ gnu/CORBA/Version.java 14 Sep 2005 21:04:42 -0000
@@ -99,6 +99,15 @@
Version that = (Version) other;
return same(that);
}
+
+ /**
+ * Get the hashcode, higher 8 bits being the major version and lower 8 bits
+ * the minor version.
+ */
+ public int hashCode()
+ {
+ return major << 8 | minor;
+ }
/**
* Read from the input stream, major number first.
@@ -203,4 +212,5 @@
throw new MARSHAL("IOException while writing message header");
}
}
+
}
Index: gnu/CORBA/gnuAny.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/CORBA/gnuAny.java,v
retrieving revision 1.6
diff -u -r1.6 gnuAny.java
--- gnu/CORBA/gnuAny.java 7 Aug 2005 17:17:43 -0000 1.6
+++ gnu/CORBA/gnuAny.java 14 Sep 2005 20:56:16 -0000
@@ -62,19 +62,15 @@
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.TypeCodeHolder;
-import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.ValueBaseHolder;
import org.omg.CORBA.portable.BoxedValueHelper;
import org.omg.CORBA.portable.Streamable;
-import java.io.IOException;
import java.io.Serializable;
-
import java.lang.reflect.Field;
-
import java.math.BigDecimal;
-
import java.util.Arrays;
+import java.util.zip.Adler32;
/**
* The implementation of address@hidden Any}.
@@ -206,6 +202,28 @@
byte[] bb = b.buffer.toByteArray();
return Arrays.equals(ba, bb);
+ }
+
+ /**
+ * Get the content - dependent hashcode.
+ */
+ public int hashCode()
+ {
+ if (has == null)
+ return type().kind().value();
+ else
+ {
+ Adler32 adler = new Adler32();
+
+ cdrBufOutput a = new cdrBufOutput();
+ a.setOrb(orb);
+ write_value(a);
+
+ adler.update(a.buffer.toByteArray());
+ adler.update(type().kind().value());
+
+ return (int) adler.getValue() & Integer.MAX_VALUE;
+ }
}
/**
Index: gnu/CORBA/Poa/activeObjectMap.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/CORBA/Poa/activeObjectMap.java,v
retrieving revision 1.1
diff -u -r1.1 activeObjectMap.java
--- gnu/CORBA/Poa/activeObjectMap.java 22 Jul 2005 16:57:47 -0000 1.1
+++ gnu/CORBA/Poa/activeObjectMap.java 14 Sep 2005 20:34:38 -0000
@@ -142,17 +142,6 @@
{
deactivated = state;
}
-
- public boolean equals(java.lang.Object other)
- {
- if (other instanceof Obj)
- {
- Obj o = (Obj) other;
- return o.object.equals(object);
- }
- else
- return false;
- }
}
/**
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cp-patches] FYI: Making hashCode consistent with equals in gnu.CORBA,
Meskauskas Audrius <=