Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6420335

(fmspec) incorrect statement about MarshalledObject.hashCode

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 1.2.1
    • core-libs
    • Fix Understood
    • generic
    • generic

      In section 4.9 of the Java Remote Method Invocation Specification document, which is about java.rmi.MarshalledObject, there is the following statement about the behavior of MarshalledObject's Object.hashCode implementation:

          The hashCode of the marshalled representation of the object is the
          same as the object passed to the constructor.

      which is incorrect-- the behavior of MarshalledObject.hashCode is just a function of the non-codebase bytes of the contained serialized stream (the hash code value is actually computed upon construction of a MarshalledObject and it is stored in a serializable field of the class). And the specified behavior would be problematic, because the hash code of objects passed to MarshalledObject might not be consistent across VMs even when the serialized forms of the objects (which is what counts for MarshalledObject.equals) are identical, and thus the general contract of Object.hashCode would be violated. Therefore, it is the specification that should be corrected on this point.

      Also, the particular algorithm used by MarshalledObject's constructor in computing the value to be used by MarshalledObject.hashCode and stored in the serializable field should be specified concretely. While it is typically undesirable to specify hash code algorithms for concrete classes, because the computed value is serialized with the object, it would seem necessary to use a uniform algorithm for interoperability.

            Unassigned Unassigned
            peterjones Peter Jones (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: