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

REGRESSION: javax.swing.JFileChooser is not serializable under 1.5.0.

    Details

    • Subcomponent:
    • Resolved In Build:
      b64
    • CPU:
      x86
    • OS:
      windows_xp

      Description

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

      ADDITIONAL OS VERSION INFORMATION :
      Windows XP Professional SP2

      A DESCRIPTION OF THE PROBLEM :
      JFileChooser is not serializable. The API documentation indicates that it implements Serializable, and my experience is that it can be serialized in releases prior to 1.5.0. In 1.5.0 attempting to serialize JFileChooser produces the following error:

      java.io.NotSerializableException: javax.swing.JFileChooser$WeakPCL

      My code returns a JFileChooser as the result of a remote procedure, and this no longer works in 1.5.0. However, see below for a simpler way of reproducing the error.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
            JFileChooser jfc=new JFileChooser();
             try {
                  File f=new File("foo");
                  ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream(f));
                  oos.writeObject(jfc);
              }
              catch (Exception e) {
                  e.printStackTrace();
              }

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Under 1.4.2 this works without error, under 1.5.0 it produces a java.io.NotSerializableException.
      ACTUAL -
      Doesn't work. See below for error message.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.io.NotSerializableException: javax.swing.JFileChooser$WeakPCL
              at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1075)
              at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1369)
              at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:380)
              at javax.swing.JFileChooser.writeObject(JFileChooser.java:1806)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:585)
              at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:890)
              at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1333)
              at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284)
              at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
              at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:291)
              at JFtester.main(JFtester.java:30)
      Exception in thread "Basic L&F File Loading Thread" java.lang.NullPointerException
              at javax.swing.JFileChooser.isTraversable(JFileChooser.java:1553)
              at javax.swing.plaf.basic.BasicDirectoryModel$LoadFilesThread.run(BasicDirectoryModel.java:222)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
           JFileChooser jfc=new JFileChooser();
             try {
                  File f=new File("foo");
                  ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream(f));
                  oos.writeObject(jfc);
              }
              catch (Exception e) {
                  e.printStackTrace();
              }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Unfortunately I have not found one, but would like to hear of it if you have one.

      Release Regression From : 5.0
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.
      ###@###.### 2005-1-10 11:13:33 GMT

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                loneid Leonid Popov (Inactive)
                Reporter:
                jssunw Jitender S (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: