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

(ann) Serialized form of annotations persists objects from sun.* packages

    XMLWordPrintable

    Details

    • Subcomponent:
    • Understanding:
      Fix Understood
    • CPU:
      x86
    • OS:
      windows_98

      Description

      FULL PRODUCT VERSION :
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
      Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Win98SE

      A DESCRIPTION OF THE PROBLEM :
      When an annotation is persisted, the serialized form contains a reference to sun.reflect.annotation.AnnotationInvocationHandler. This is a non-standard class, and may not be present if the object is deserialized on another machine with a non-Sun Java platform, leading to an error.

      Further, as sun.* packages are not guaranteed to be compatible across JDK releases, annotations serialzed with one version are not guaranteed to work in the next. And yet the spec says that annotations are meant to be fully serializable.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      See the source below

      ACTUAL -
      The output file contained the serialized object from the sun.* package

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.io.*;
      import java.lang.annotation.*;

      @Y
      public abstract class X {
          public static void main(String[] args) throws Exception {
              Object ann = X.class.getAnnotation(Y.class);
              ObjectOutputStream os = new ObjectOutputStream(
                  new FileOutputStream("x.ser"));
              os.writeObject(ann);
              os.close();
          }
      }

      @Retention(RetentionPolicy.RUNTIME)
      @interface Y { }


      ---------- END SOURCE ----------
      ###@###.### 2005-05-16 09:00:52 GMT

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              darcy Joe Darcy
              Reporter:
              ndcosta Nelson Dcosta (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Dates

                Created:
                Updated:
                Imported:
                Indexed: