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

TimeZone factory methods return instance not deserializable in previous releases

XMLWordPrintable



      Name: nt126004 Date: 02/28/2002


      FULL PRODUCT VERSION :
      java version "1.4.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
      Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

      FULL OPERATING SYSTEM VERSION :
      Microsoft Windows 2000 [Version 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      Serialize a TimeZone to file from JDK1.4. Deserializing
      from JDK1.3 throws a ClassNotFoundException.

      This is related to bug 4490827 which has been closed - the
      test source code below comes from there modified slightly.

      REGRESSION. Last worked in version 1.3.1

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Run the test program in JDK1.4.
      2. Comment out writeObject(); in main, and compile and run
      in JDK1.3.1_02.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Results from step 1:

       tz=sun.util.calendar.ZoneInfo
      [id="GMT",offset=0,dstSavings=0,useDaylight=false,transition
      s=0,lastRule=null]


      Results from step 2:

      See the exception stack trace in Error Messages.


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.lang.ClassNotFoundException: sun.util.calendar.ZoneInfo
      at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
      at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:195)
      at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:654)
      at java.io.ObjectInputStream.inputClassDescriptor
      (ObjectInputStream.java:918)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:366)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
      at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1186)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:386)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
      at com.bglobal.gimg.glm.test.TimeZoneTest.readObject
      (TimeZoneTest.java:34)
      at com.bglobal.gimg.glm.test.TimeZoneTest.main(TimeZoneTest.java:15)

      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.io.FileInputStream;
      import java.io.FileOutputStream;
      import java.io.ObjectInputStream;
      import java.io.ObjectOutputStream;
      import java.util.TimeZone;

      public class TimeZoneTest {

          static String fName = "tmp";

          public static void main(String[] arg) throws Exception {
              writeObject();
              readObject();
          }

          static void writeObject() throws Exception {

              FileOutputStream fos = new FileOutputStream(fName);
              ObjectOutputStream out = new ObjectOutputStream(fos);

              TimeZone tz = TimeZone.getTimeZone("GMT");
              out.writeObject(tz);

              out.flush();
              out.close();
          }

          static void readObject() throws Exception {
              FileInputStream fis = new FileInputStream(fName);
              ObjectInputStream in = new ObjectInputStream(fis);

              TimeZone tz = (TimeZone) in.readObject();
              System.out.println(" tz=" + tz);

              in.close();
          }
      }

      ---------- END SOURCE ----------
      (Review ID: 139756)
      ======================================================================

            okutsu Masayoshi Okutsu
            nthompsosunw Nathanael Thompson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: