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

cannot deserialize array of class whose package access has changed

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.4.0
    • core-libs
    • None
    • beta3
    • generic
    • generic
    • Verified

      Suppose an instance of some non-array class C is serialized from VM1 to VM2, and
      the package access of the class differs between the two VMs (e.g., VM1 has
      loaded a version of C which is public, whereas VM2 has loaded a package-private
      version). In this case, deserialization of C can still succeed provided that
      C has declared an explicit serialVersionUID which is the same in both
      reading and writing VMs.

      However, if an array of C is written to the stream, then deserialization will
      unavoidably fail with an InvalidClassException due to mismatched
      serialVersionUIDs, since the package access of an array class follows that
      of its component class, and package access affects default serialVersionUIDs
      (which there is no way to override for array classes). The attached
      example demonstrates this problem. Note that this problem has been present
      in serialization since at least JDK 1.2.

      One solution would be to disable serialVersionUID checks for array classes,
      since such checks seem to serve little purpose, and are already bypassed
      in cases where the array name differs between sender and received (such as
      when a class has been moved from one package to another).

            mwarressunw Michael Warres (Inactive)
            mwarressunw Michael Warres (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: