Issue 2529: RMI style repository ID hash code (orb_revision) Source: (, ) Nature: Uncategorized Issue Severity: Summary: Summary: There is a problem with the currently defined algorithm for computing the hash code component of the RMI Hashed Format repository ID as defined in section 10.6.2. Because it is based only on the structural information in the most derived Java class and does not take into acoount any superclass information, it can give a "false positive" result when the state of a superclass changes but the state of the most derived class does not. This is a core RTF issue since the affected text is in chapter 10. Resolution: Replace the currently defined algorithm with one that fixes the problem as described below Revised Text: In section 10.6.2, replace the paragraph starting "The hash code is" by the following text: For classes that do not implement java.io.Serializable, and for interfaces, the hash code is always zero, and the RepositoryID does not contain a serial version UID. For classes that implement java.io.Externalizable, the hash code is always the 64-bit value 1. For classes that implement java.io.Serializable but not java.io.Externalizable, the hash code is a 64-bit hash of a stream of bytes. An instance of java.lang.DataOutputStream is used to convert primitive data types to a sequence of bytes. The sequence of items in the stream is as follows: 1. The hash code of the superclass, written as a 64-bit long. 2. The value 1 if the class has no writeObject method, or the value 2 if the class has a writeObject method, written as a 32-bit integer. 3. For each field of the class that is mapped to IDL, sorted lexicographically by Java field name, in increasing order: a. Java field name, in UTF encoding b. field descriptor, as defined by the Java Virtual Machine Specification, in UTF encoding The National Institute of Standards and Technology (NIST) Secure Hash Algorithm (SHA-1) is executed on the stream of bytes produced by DataOutputStream, producing a 20 byte array of values, sha[0..19]. The hash code is assembled from the first 8 bytes of this array as follows: long hash = 0; for (int i = 0; i < Math.min(8, sha.length); i++) { hash += (long)(sha[i] & 255) << (i * 8); } Actions taken: March 12, 1999: received issue September 16, 1999: closed issue Discussion: End of Annotations:===== Date: Fri, 12 Mar 1999 10:48:32 +0000 From: Simon Nash Organization: IBM X-Accept-Language: en To: issues@omg.org CC: orb_revision@omg.org, Steve Lewallen , Bryan Atsatt , java2idl-rtf@omg.org Subject: RMI style repository ID hash code There is a problem with the currently defined algorithm for computing the hash code component of the RMI Hashed Format repository ID as defined in section 10.6.2. Because it is based only on the structural information in the most derived Java class and does not take into acoount any superclass information, it can give a "false positive" result when the state of a superclass changes but the state of the most derived class does not. This is a core RTF issue since the affected text is in chapter 10. Proposed resolution: In section 10.6.2, replace the paragraph starting "The hash code is" by the following text: The hash code is a 64-bit hash of a stream of bytes. An instance of java.lang.DataOutputStream is used to convert primitive data types to a sequence of bytes. The sequence of items in the stream is as follows: 1. The hash code of the superclass, or zero if there is no superclass, written as a 64-bit long. 2. The value 1 if the class is not externalizable and has no writeObject method, the value 2 if the class is not externalizable but has a writeObject method, or the value 3 if the class is externalizable, written as a 32-bit integer. 3. For each field of the class that is mapped to IDL, sorted lexicographically by Java field name, in increasing order: a. Java field name, in UTF encoding b. field descriptor, in UTF encoding, as defined by the Java Virtual Machine Specification The National Institute of Standards and Technology (NIST) Secure Hash Algorithm (SHA-1) is executed on the stream of bytes produced by DataOutputStream, producing a 20 byte array of values, sha[0..19]. The structural hash is assembled from the first 8 bytes of this array as follows: long hash = 0; for (int i = 0; i < Math.min(8, sha.length); i++) { hash += (long)(sha[i] & 255) << (i * 8); } Simon -- Simon C Nash, Technology Architect, IBM Java Technology Centre Tel. +44-1962-815156 Fax +44-1962-818999 Hursley, England Internet: nash@hursley.ibm.com Lotus Notes: Simon Nash@ibmgb Date: Tue, 16 Mar 1999 13:18:54 +0000 From: Simon Nash Organization: IBM X-Accept-Language: en To: jis@fpk.hp.com CC: orb_revision@omg.org Subject: Issue 2529 - RMI hash codes Jishnu, The Java to IDL RTF has been revising the proposed new algorithm and the following is the final final version. Simon - - - - - - - - Proposed resolution: In section 10.6.2, replace the paragraph starting "The hash code is" by the following text: For classes that do not implement java.io.Serializable, and for interfaces, the hash code is always zero, and the RepositoryID does not contain a serial version UID. For classes that implement java.io.Externalizable, the hash code is always the 64-bit value 1. For classes that implement java.io.Serializable but not java.io.Externalizable, the hash code is a 64-bit hash of a stream of bytes. An instance of java.lang.DataOutputStream is used to convert primitive data types to a sequence of bytes. The sequence of items in the stream is as follows: 1. The hash code of the superclass, written as a 64-bit long. 2. The value 1 if the class has no writeObject method, or the value 2 if the class has a writeObject method, written as a 32-bit integer. 3. For each field of the class that is mapped to IDL, sorted lexicographically by Java field name, in increasing order: a. Java field name, in UTF encoding b. field descriptor, as defined by the Java Virtual Machine Specification, in UTF encoding The National Institute of Standards and Technology (NIST) Secure Hash Algorithm (SHA-1) is executed on the stream of bytes produced by DataOutputStream, producing a 20 byte array of values, sha[0..19]. The hash code is assembled from the first 8 bytes of this array as follows: long hash = 0; for (int i = 0; i < Math.min(8, sha.length); i++) { hash += (long)(sha[i] & 255) << (i * 8); } -- Simon C Nash, Technology Architect, IBM Java Technology Centre Tel. +44-1962-815156 Fax +44-1962-818999 Hursley, England Internet: nash@hursley.ibm.com Lotus Notes: Simon Nash@ibmgb