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

java.awt.Frame can not be serialized

    Details

    • Subcomponent:
    • Resolved In Build:
      beta
    • CPU:
      sparc
    • OS:
      solaris_2.6

      Description



      Name: ooR10001 Date: 04/14/2000


      If method setIconImage() is invoked with a non-Serializable parameter,
      the object is no longer serializable.
      For example, it could be invoked with instance of java.awt.Image.
      In this case object's field 'icon' will be initialized with non-Serializable
      class instance of java.awt.Image. This causes the problem.
       
      The test example to reproduce the bug:
      -------------------------------------------------------------
      import java.io.FileOutputStream;
      import java.io.ObjectOutputStream;

      public class test {

        public static void main(String[] args) {
          try {
              java.awt.Frame obj = new java.awt.Frame();
              obj.setIconImage(new java.awt.image.BufferedImage(
                  8, 8, java.awt.image.BufferedImage.TYPE_BYTE_BINARY));

              FileOutputStream ostream = new FileOutputStream("gold.tmp");
              ObjectOutputStream objos = new ObjectOutputStream(ostream);
              objos.writeObject(obj);
              objos.close();

          } catch (java.io.IOException e) {
              e.printStackTrace();
          }
        }

      }
      -------------------------------------------------------------
      Test output:

      java.io.NotSerializableException: java.awt.image.BufferedImage
              at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1148)
              at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:366)
              at
      java.io.ObjectOutputStream.outputClassFields(ObjectOutputStream.java:1841)
              at
      java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:480)
              at java.awt.Frame.writeObject(Frame.java:718)
              at java.lang.reflect.Method.invoke(Native Method)
              at
      java.io.ObjectOutputStream.invokeObjectWriter(ObjectOutputStream.java:1878)
              at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1210)
              at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:366)
              at test.main(test.java:14)
      <-------------------------------------------------------------

      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                rraysunw Richard Ray (Inactive)
                Reporter:
                oovsunw Oov Oov (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: