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

java.applet.Applet serialized form in jdk1.3 is not compatible with jdk1.4

XMLWordPrintable

    • beta
    • sparc
    • solaris_2.6



      Name: dsR10051 Date: 10/18/2000


      The java.applet.Applet object serialized under jdk1.3 fails to be
      deserialized under jdk1.4 due to the incompatibility of the classon
      jdk1.3 and jdk1.4 platforms.

      Here is a minimized test:
      import java.io.*;
      import java.applet.*;

      public class SomeBeanApplet2 {

          public static void main (String[] args) {
              Applet anObject = null;

              if (args[0].equals("write")) {
                  anObject = new Applet();

                  FileOutputStream file;
                  ObjectOutputStream freezer;

                  // create a test object
                  anObject = new Applet();
                  try {
                      file = new FileOutputStream("Applet.ser");
                      freezer = new ObjectOutputStream(file);
                      freezer.writeObject( anObject );
                      freezer.close();
                  } catch (IOException noIO) {
                      System.out.println("IO error occurred: " + noIO);
                      System.exit(1);
                  }
                  System.exit(0);
              } else if (args[0].equals("read")) {
                  FileInputStream file;
                  ObjectInputStream freezer;

                  try {
                      file = new FileInputStream("Applet.ser");
                      freezer = new ObjectInputStream(file);
                      anObject = (Applet) freezer.readObject();
                  } catch (IOException noIO) {
                      System.out.println("IO error occurred: " + noIO);
                      System.exit(1);
                  } catch (ClassNotFoundException noClass) {
                      System.out.println("Unexpected ClassNotFoundException: " + noClass);
                      System.exit(1);
                  }
                  System.out.println("OKAY");
                  System.exit(0);
              }
          }
      }

      --- Output ---
      %/set/java/jdk1.3/solaris/bin/java SomeBeanApplet2 write
      %/set/java/jdk1.4/solaris/bin/java SomeBeanApplet2 read
      IO error occurred: java.io.OptionalDataException
      %

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

            dmendenhsunw David Mendenhall (Inactive)
            sdasunw Sda Sda (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: