diff options
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/Freeze/SharedDbEnv.java | 4 | ||||
-rw-r--r-- | java/src/Ice/LocalObject.java | 2 | ||||
-rw-r--r-- | java/src/Ice/LocalObjectImpl.java | 6 | ||||
-rw-r--r-- | java/src/Ice/Object.java | 5 | ||||
-rw-r--r-- | java/src/Ice/ObjectImpl.java | 9 | ||||
-rw-r--r-- | java/src/Ice/ObjectPrx.java | 5 | ||||
-rw-r--r-- | java/src/Ice/ObjectPrxHelperBase.java | 9 | ||||
-rw-r--r-- | java/src/Ice/ProxyIdentityFacetKey.java | 6 | ||||
-rw-r--r-- | java/src/Ice/ProxyIdentityKey.java | 5 | ||||
-rw-r--r-- | java/src/IceInternal/HashUtil.java | 120 | ||||
-rw-r--r-- | java/src/IceInternal/OpaqueEndpointI.java | 12 | ||||
-rw-r--r-- | java/src/IceInternal/Reference.java | 23 | ||||
-rw-r--r-- | java/src/IceInternal/RoutableReference.java | 4 | ||||
-rw-r--r-- | java/src/IceInternal/TcpConnector.java | 13 | ||||
-rw-r--r-- | java/src/IceInternal/TcpEndpointI.java | 17 | ||||
-rw-r--r-- | java/src/IceInternal/UdpConnector.java | 15 | ||||
-rw-r--r-- | java/src/IceInternal/UdpEndpointI.java | 21 | ||||
-rw-r--r-- | java/src/IceSSL/ConnectorI.java | 13 | ||||
-rw-r--r-- | java/src/IceSSL/EndpointI.java | 17 |
19 files changed, 204 insertions, 102 deletions
diff --git a/java/src/Freeze/SharedDbEnv.java b/java/src/Freeze/SharedDbEnv.java index ab7163c20b7..76bf51d78e1 100644 --- a/java/src/Freeze/SharedDbEnv.java +++ b/java/src/Freeze/SharedDbEnv.java @@ -545,7 +545,9 @@ public class SharedDbEnv implements com.sleepycat.db.ErrorHandler, Runnable public int hashCode() { - return envName.hashCode() ^ communicator.hashCode(); + int h = 5381; + h = IceInternal.HashUtil.hashAdd(h, envName); + return IceInternal.HashUtil.hashAdd(h, communicator); } } diff --git a/java/src/Ice/LocalObject.java b/java/src/Ice/LocalObject.java index 03cbba57d9b..335198e6f01 100644 --- a/java/src/Ice/LocalObject.java +++ b/java/src/Ice/LocalObject.java @@ -17,6 +17,4 @@ public interface LocalObject boolean equals(java.lang.Object rhs); java.lang.Object clone() throws java.lang.CloneNotSupportedException; - - int ice_hash(); } diff --git a/java/src/Ice/LocalObjectImpl.java b/java/src/Ice/LocalObjectImpl.java index c2634d3e15e..da39eac7dab 100644 --- a/java/src/Ice/LocalObjectImpl.java +++ b/java/src/Ice/LocalObjectImpl.java @@ -19,10 +19,4 @@ public abstract class LocalObjectImpl implements LocalObject, java.lang.Cloneabl { return super.clone(); } - - public int - ice_hash() - { - return hashCode(); - } } diff --git a/java/src/Ice/Object.java b/java/src/Ice/Object.java index 70461f26b86..20184f6657f 100644 --- a/java/src/Ice/Object.java +++ b/java/src/Ice/Object.java @@ -22,11 +22,6 @@ public interface Object **/ java.lang.Object clone() throws java.lang.CloneNotSupportedException; - /** - * @deprecated This method is deprecated, use hashCode instead. - **/ - int ice_hash(); - /** * Tests whether this object supports a specific Slice interface. * diff --git a/java/src/Ice/ObjectImpl.java b/java/src/Ice/ObjectImpl.java index 7ff5636cc0f..a1e0fb5c7a4 100644 --- a/java/src/Ice/ObjectImpl.java +++ b/java/src/Ice/ObjectImpl.java @@ -43,15 +43,6 @@ public abstract class ObjectImpl implements Object, java.lang.Cloneable, java.io return o; } - /** - * @deprecated - **/ - public int - ice_hash() - { - return hashCode(); - } - public final static String[] __ids = { "::Ice::Object" diff --git a/java/src/Ice/ObjectPrx.java b/java/src/Ice/ObjectPrx.java index 119482ba45e..17587de0a9e 100644 --- a/java/src/Ice/ObjectPrx.java +++ b/java/src/Ice/ObjectPrx.java @@ -15,11 +15,6 @@ package Ice; public interface ObjectPrx { /** - * @deprecated This method is deprecated, use hashCode instead. - **/ - int ice_getHash(); - - /** * Returns the communicator that created this proxy. * * @return The communicator that created this proxy. diff --git a/java/src/Ice/ObjectPrxHelperBase.java b/java/src/Ice/ObjectPrxHelperBase.java index 9a1de69d685..fd6deac1100 100644 --- a/java/src/Ice/ObjectPrxHelperBase.java +++ b/java/src/Ice/ObjectPrxHelperBase.java @@ -26,15 +26,6 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable } /** - * @deprecated - **/ - public final int - ice_getHash() - { - return _reference.hashCode(); - } - - /** * Returns the communicator that created this proxy. * * @return The communicator that created this proxy. diff --git a/java/src/Ice/ProxyIdentityFacetKey.java b/java/src/Ice/ProxyIdentityFacetKey.java index f23bf093952..a2b859e958d 100644 --- a/java/src/Ice/ProxyIdentityFacetKey.java +++ b/java/src/Ice/ProxyIdentityFacetKey.java @@ -17,6 +17,7 @@ package Ice; * @see ProxyIdentityAndFacetCompare * @see ProxyIdentityCompare * @see ProxyIdentityKey + * **/ public class ProxyIdentityFacetKey { @@ -35,8 +36,9 @@ public class ProxyIdentityFacetKey // _identity = proxy.ice_getIdentity(); _facet = proxy.ice_getFacet(); - int h = _identity.hashCode(); - h = 5 * h + _facet.hashCode(); + int h = 5381; + h = IceInternal.HashUtil.hashAdd(h, _identity); + h = IceInternal.HashUtil.hashAdd(h, _facet); _hashCode = h; } diff --git a/java/src/Ice/ProxyIdentityKey.java b/java/src/Ice/ProxyIdentityKey.java index a008ad63869..6bfe9b640ab 100644 --- a/java/src/Ice/ProxyIdentityKey.java +++ b/java/src/Ice/ProxyIdentityKey.java @@ -17,6 +17,7 @@ package Ice; * @see ProxyIdentityCompare * @see ProxyIdentityAndFacetCompare * @see ProxyIdentityFacetKey + * **/ public class ProxyIdentityKey { @@ -34,7 +35,9 @@ public class ProxyIdentityKey // Cache the identity and its hash code. // _identity = proxy.ice_getIdentity(); - _hashCode = _identity.hashCode(); + int h = 5381; + h = IceInternal.HashUtil.hashAdd(h, _identity); + _hashCode = h; } /** diff --git a/java/src/IceInternal/HashUtil.java b/java/src/IceInternal/HashUtil.java new file mode 100644 index 00000000000..520254bbc64 --- /dev/null +++ b/java/src/IceInternal/HashUtil.java @@ -0,0 +1,120 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package IceInternal; + +public final class HashUtil +{ + public static int + hashAdd(int hashCode, boolean value) + { + return ((hashCode << 5) + hashCode) ^ (value ? 0 : 1); + } + + public static int + hashAdd(int hashCode, short value) + { + return ((hashCode << 5) + hashCode) ^ (int)(2654435761l * value); + } + + public static int + hashAdd(int hashCode, byte value) + { + return ((hashCode << 5) + hashCode) ^ (int)(2654435761l * value); + } + + public static int + hashAdd(int hashCode, int value) + { + return ((hashCode << 5) + hashCode) ^ (int)(2654435761l * value); + } + + public static int + hashAdd(int hashCode, long value) + { + return ((hashCode << 5) + hashCode) ^ (int)(value ^ (value >>> 32)); + } + + public static int + hashAdd(int hashCode, float value) + { + return ((hashCode << 5) + hashCode) ^ Float.floatToIntBits(value); + } + + public static int + hashAdd(int hashCode, double value) + { + long v = Double.doubleToLongBits(value); + return ((hashCode << 5) + hashCode) ^ (int)(v ^ (v >>> 32)); + } + + public static int + hashAdd(int hashCode, java.lang.Object value) + { + if(value != null) + { + hashCode = ((hashCode << 5) + hashCode) ^ value.hashCode(); + } + return hashCode; + } + + public static int + hashAdd(int hashCode, boolean[] arr) + { + return ((hashCode << 5) + hashCode) ^ java.util.Arrays.hashCode(arr); + } + + public static int + hashAdd(int hashCode, byte[] arr) + { + return ((hashCode << 5) + hashCode) ^ java.util.Arrays.hashCode(arr); + } + + public static int + hashAdd(int hashCode, char[] arr) + { + return ((hashCode << 5) + hashCode) ^ java.util.Arrays.hashCode(arr); + } + + public static int + hashAdd(int hashCode, double[] arr) + { + return ((hashCode << 5) + hashCode) ^ java.util.Arrays.hashCode(arr); + } + + public static int + hashAdd(int hashCode, float[] arr) + { + return ((hashCode << 5) + hashCode) ^ java.util.Arrays.hashCode(arr); + } + + public static int + hashAdd(int hashCode, int[] arr) + { + return ((hashCode << 5) + hashCode) ^ java.util.Arrays.hashCode(arr); + } + + public static int + hashAdd(int hashCode, long[] arr) + { + return ((hashCode << 5) + hashCode) ^ java.util.Arrays.hashCode(arr); + } + + public static int + hashAdd(int hashCode, Object[] arr) + { + return ((hashCode << 5) + hashCode) ^ java.util.Arrays.hashCode(arr); + } + + public static int + hashAdd(int hashCode, short[] arr) + { + return ((hashCode << 5) + hashCode) ^ java.util.Arrays.hashCode(arr); + } +} diff --git a/java/src/IceInternal/OpaqueEndpointI.java b/java/src/IceInternal/OpaqueEndpointI.java index 3982b095415..f40763a418a 100644 --- a/java/src/IceInternal/OpaqueEndpointI.java +++ b/java/src/IceInternal/OpaqueEndpointI.java @@ -433,13 +433,11 @@ final class OpaqueEndpointI extends EndpointI private void calcHashValue() { - _hashCode = _type; - _hashCode = 5 * _hashCode + _rawEncoding.major; - _hashCode = 5 * _hashCode + _rawEncoding.minor; - for(int i = 0; i < _rawBytes.length; i++) - { - _hashCode = 5 * _hashCode + _rawBytes[i]; - } + int h = 5381; + h = IceInternal.HashUtil.hashAdd(h, _type); + h = IceInternal.HashUtil.hashAdd(h, _rawEncoding); + h = IceInternal.HashUtil.hashAdd(h, _rawBytes); + _hashCode = h; } private short _type; diff --git a/java/src/IceInternal/Reference.java b/java/src/IceInternal/Reference.java index 8a1357d8401..2e6e1f4af1a 100644 --- a/java/src/IceInternal/Reference.java +++ b/java/src/IceInternal/Reference.java @@ -201,20 +201,23 @@ public abstract class Reference implements Cloneable return _hashValue; } - int h = _mode; - - h = 5 * h + _identity.hashCode(); - - h = 5 * h + _context.hashCode(); - - h = 5 * h + _facet.hashCode(); - - h = 5 * h + (_secure ? 1 : 0); + int h = 5381; + h = IceInternal.HashUtil.hashAdd(h, _mode); + h = IceInternal.HashUtil.hashAdd(h, _secure); + h = IceInternal.HashUtil.hashAdd(h, _identity); + h = IceInternal.HashUtil.hashAdd(h, _context); + h = IceInternal.HashUtil.hashAdd(h, _facet); + h = IceInternal.HashUtil.hashAdd(h, _overrideCompress); + if(_overrideCompress) + { + h = IceInternal.HashUtil.hashAdd(h, _compress); + } + h = IceInternal.HashUtil.hashAdd(h, _encoding); _hashValue = h; _hashInitialized = true; - return h; + return _hashValue; } // diff --git a/java/src/IceInternal/RoutableReference.java b/java/src/IceInternal/RoutableReference.java index 2e70432de90..e1f9607a4a8 100644 --- a/java/src/IceInternal/RoutableReference.java +++ b/java/src/IceInternal/RoutableReference.java @@ -369,9 +369,7 @@ public class RoutableReference extends Reference if(!_hashInitialized) { super.hashCode(); // Initializes _hashValue. - - // Add hash of adapter ID to base hash. - _hashValue = 5 * _hashValue + _adapterId.hashCode(); + _hashValue = IceInternal.HashUtil.hashAdd(_hashValue, _adapterId); } return _hashValue; } diff --git a/java/src/IceInternal/TcpConnector.java b/java/src/IceInternal/TcpConnector.java index 7947a4152f8..71503101dc5 100644 --- a/java/src/IceInternal/TcpConnector.java +++ b/java/src/IceInternal/TcpConnector.java @@ -80,12 +80,13 @@ final class TcpConnector implements Connector _encoding = encoding; _connectionId = connectionId; - _hashCode = _addr.getAddress().getHostAddress().hashCode(); - _hashCode = 5 * _hashCode + _addr.getPort(); - _hashCode = 5 * _hashCode + _timeout; - _hashCode = 5 * _hashCode + _protocol.hashCode(); - _hashCode = 5 * _hashCode + _encoding.hashCode(); - _hashCode = 5 * _hashCode + _connectionId.hashCode(); + _hashCode = 5381; + _hashCode = IceInternal.HashUtil.hashAdd(_hashCode , _addr.getAddress().getHostAddress()); + _hashCode = IceInternal.HashUtil.hashAdd(_hashCode , _addr.getPort()); + _hashCode = IceInternal.HashUtil.hashAdd(_hashCode , _timeout); + _hashCode = IceInternal.HashUtil.hashAdd(_hashCode , _protocol); + _hashCode = IceInternal.HashUtil.hashAdd(_hashCode , _encoding); + _hashCode = IceInternal.HashUtil.hashAdd(_hashCode , _connectionId); } public boolean diff --git a/java/src/IceInternal/TcpEndpointI.java b/java/src/IceInternal/TcpEndpointI.java index 0d2ab229193..18426c4494d 100644 --- a/java/src/IceInternal/TcpEndpointI.java +++ b/java/src/IceInternal/TcpEndpointI.java @@ -556,13 +556,16 @@ final class TcpEndpointI extends EndpointI private void calcHashValue() { - _hashCode = _host.hashCode(); - _hashCode = 5 * _hashCode + _port; - _hashCode = 5 * _hashCode + _timeout; - _hashCode = 5 * _hashCode + _protocol.hashCode(); - _hashCode = 5 * _hashCode + _encoding.hashCode(); - _hashCode = 5 * _hashCode + _connectionId.hashCode(); - _hashCode = 5 * _hashCode + (_compress ? 1 : 0); + int h = 5381; + h = IceInternal.HashUtil.hashAdd(h, Ice.TCPEndpointType.value); + h = IceInternal.HashUtil.hashAdd(h, _host); + h = IceInternal.HashUtil.hashAdd(h, _port); + h = IceInternal.HashUtil.hashAdd(h, _timeout); + h = IceInternal.HashUtil.hashAdd(h, _protocol); + h = IceInternal.HashUtil.hashAdd(h, _encoding); + h = IceInternal.HashUtil.hashAdd(h, _connectionId); + h = IceInternal.HashUtil.hashAdd(h, _compress); + _hashCode = h; } private Instance _instance; diff --git a/java/src/IceInternal/UdpConnector.java b/java/src/IceInternal/UdpConnector.java index 1d231ef6b31..152e838dd58 100644 --- a/java/src/IceInternal/UdpConnector.java +++ b/java/src/IceInternal/UdpConnector.java @@ -56,13 +56,14 @@ final class UdpConnector implements Connector _encoding = encoding; _connectionId = connectionId; - _hashCode = _addr.getAddress().getHostAddress().hashCode(); - _hashCode = 5 * _hashCode + _addr.getPort(); - _hashCode = 5 * _hashCode + _mcastInterface.hashCode(); - _hashCode = 5 * _hashCode + _protocol.hashCode(); - _hashCode = 5 * _hashCode + _encoding.hashCode(); - _hashCode = 5 * _hashCode + _mcastTtl; - _hashCode = 5 * _hashCode + _connectionId.hashCode(); + _hashCode = 5381; + _hashCode = IceInternal.HashUtil.hashAdd(_hashCode , _addr.getAddress().getHostAddress()); + _hashCode = IceInternal.HashUtil.hashAdd(_hashCode , _addr.getPort()); + _hashCode = IceInternal.HashUtil.hashAdd(_hashCode , _mcastInterface); + _hashCode = IceInternal.HashUtil.hashAdd(_hashCode , _protocol); + _hashCode = IceInternal.HashUtil.hashAdd(_hashCode , _encoding); + _hashCode = IceInternal.HashUtil.hashAdd(_hashCode , _mcastTtl); + _hashCode = IceInternal.HashUtil.hashAdd(_hashCode , _connectionId); } public boolean diff --git a/java/src/IceInternal/UdpEndpointI.java b/java/src/IceInternal/UdpEndpointI.java index d3a8c23f27f..8e78a33079c 100644 --- a/java/src/IceInternal/UdpEndpointI.java +++ b/java/src/IceInternal/UdpEndpointI.java @@ -583,15 +583,18 @@ final class UdpEndpointI extends EndpointI private void calcHashValue() { - _hashCode = _host.hashCode(); - _hashCode = 5 * _hashCode + _port; - _hashCode = 5 * _hashCode + _mcastInterface.hashCode(); - _hashCode = 5 * _hashCode + _mcastTtl; - _hashCode = 5 * _hashCode + (_connect ? 1 : 0); - _hashCode = 5 * _hashCode + _protocol.hashCode(); - _hashCode = 5 * _hashCode + _encoding.hashCode(); - _hashCode = 5 * _hashCode + _connectionId.hashCode(); - _hashCode = 5 * _hashCode + (_compress ? 1 : 0); + int h = 5381; + h = IceInternal.HashUtil.hashAdd(h, Ice.UDPEndpointType.value); + h = IceInternal.HashUtil.hashAdd(h, _host); + h = IceInternal.HashUtil.hashAdd(h, _port); + h = IceInternal.HashUtil.hashAdd(h, _mcastInterface); + h = IceInternal.HashUtil.hashAdd(h, _mcastTtl); + h = IceInternal.HashUtil.hashAdd(h, _connect); + h = IceInternal.HashUtil.hashAdd(h, _protocol); + h = IceInternal.HashUtil.hashAdd(h, _encoding); + h = IceInternal.HashUtil.hashAdd(h, _connectionId); + h = IceInternal.HashUtil.hashAdd(h, _compress); + _hashCode = h; } private Instance _instance; diff --git a/java/src/IceSSL/ConnectorI.java b/java/src/IceSSL/ConnectorI.java index a2478eb3867..12db25b4f18 100644 --- a/java/src/IceSSL/ConnectorI.java +++ b/java/src/IceSSL/ConnectorI.java @@ -91,12 +91,13 @@ final class ConnectorI implements IceInternal.Connector _encoding = encoding; _connectionId = connectionId; - _hashCode = _addr.getAddress().getHostAddress().hashCode(); - _hashCode = 5 * _hashCode + _addr.getPort(); - _hashCode = 5 * _hashCode + _timeout; - _hashCode = 5 * _hashCode + _protocol.hashCode(); - _hashCode = 5 * _hashCode + _encoding.hashCode(); - _hashCode = 5 * _hashCode + _connectionId.hashCode(); + _hashCode = 5381; + _hashCode = IceInternal.HashUtil.hashAdd(_hashCode , _addr.getAddress().getHostAddress()); + _hashCode = IceInternal.HashUtil.hashAdd(_hashCode , _addr.getPort()); + _hashCode = IceInternal.HashUtil.hashAdd(_hashCode , _timeout); + _hashCode = IceInternal.HashUtil.hashAdd(_hashCode , _protocol); + _hashCode = IceInternal.HashUtil.hashAdd(_hashCode , _encoding); + _hashCode = IceInternal.HashUtil.hashAdd(_hashCode , _connectionId); } public boolean diff --git a/java/src/IceSSL/EndpointI.java b/java/src/IceSSL/EndpointI.java index 8ccd13656fc..e768b26d40e 100644 --- a/java/src/IceSSL/EndpointI.java +++ b/java/src/IceSSL/EndpointI.java @@ -554,13 +554,16 @@ final class EndpointI extends IceInternal.EndpointI private void calcHashValue() { - _hashCode = _host.hashCode(); - _hashCode = 5 * _hashCode + _port; - _hashCode = 5 * _hashCode + _timeout; - _hashCode = 5 * _hashCode + _protocol.hashCode(); - _hashCode = 5 * _hashCode + _encoding.hashCode(); - _hashCode = 5 * _hashCode + _connectionId.hashCode(); - _hashCode = 5 * _hashCode + (_compress ? 1 : 0); + int h = 5381; + h = IceInternal.HashUtil.hashAdd(h, EndpointType.value); + h = IceInternal.HashUtil.hashAdd(h, _host); + h = IceInternal.HashUtil.hashAdd(h, _port); + h = IceInternal.HashUtil.hashAdd(h, _timeout); + h = IceInternal.HashUtil.hashAdd(h, _protocol); + h = IceInternal.HashUtil.hashAdd(h, _encoding); + h = IceInternal.HashUtil.hashAdd(h, _connectionId); + h = IceInternal.HashUtil.hashAdd(h, _compress); + _hashCode = h; } private Instance _instance; |