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

ObjectStreamClass.packageEquals() not always correct

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.2
    • 1.4.0
    • core-libs
    • None

      The implementation of the ObjectStreamClass.packageEquals() method may
      return false positives in some cases. The current code assumes that the
      Package object obtained from Class.getPackage() identifies a "runtime"
      package--i.e., a class foo.C1 defined in class loader CL1 and a class foo.C2
      defined in class loader CL2 will return distinct (non-equals()) Package
      objects from getPackage(). This assumption is incorrect--Package instances
      can be shared among delegating class loaders--so the packageEquals() method
      can incorrectly return true if the two compared classes have the same
      package name but are loaded in separate (parent and child) class loaders.
      This can in turn result in invocation of the constructor of the wrong
      non-serializable superclass, or the wrong writeReplace/readResolve method.

            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: