JDK-4165217 : JColorChooser is not serialized
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.2.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_nt
  • CPU: x86
  • Submitted: 1998-08-10
  • Updated: 2004-04-14
  • Resolved: 2003-09-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0 tigerFixed
Related Reports
Relates :  
Description
JDK1.2FCS-E:

Please run attached code to reproduce:

java.io.NotSerializableException: com.sun.java.swing.ToolTipManager
        at java.io.ObjectOutputStream.outputObject(Compiled Code)
        at java.io.ObjectOutputStream.writeObject(Compiled Code)
        at java.io.ObjectOutputStream.outputClassFields(Compiled Code)
        at java.io.ObjectOutputStream.defaultWriteObject(Compiled Code)
        at java.io.ObjectOutputStream.outputObject(Compiled Code)
        at java.io.ObjectOutputStream.writeObject(Compiled Code)
        at java.io.ObjectOutputStream.outputClassFields(Compiled Code)
        at java.io.ObjectOutputStream.defaultWriteObject(Compiled Code)
        at java.io.ObjectOutputStream.outputObject(Compiled Code)
        at java.io.ObjectOutputStream.writeObject(Compiled Code)
        at java.util.Hashtable.writeObject(Compiled Code)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.io.ObjectOutputStream.invokeObjectWriter(ObjectOutputStream.java
:1577)
        at java.io.ObjectOutputStream.outputObject(Compiled Code)
        at java.io.ObjectOutputStream.writeObject(Compiled Code)
        at java.util.Hashtable.writeObject(Compiled Code)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.io.ObjectOutputStream.invokeObjectWriter(ObjectOutputStream.java
:1577)
        at java.io.ObjectOutputStream.outputObject(Compiled Code)
        at java.io.ObjectOutputStream.writeObject(Compiled Code)
        at java.io.ObjectOutputStream.outputClassFields(Compiled Code)
        at java.io.ObjectOutputStream.defaultWriteObject(Compiled Code)
        at com.sun.java.swing.JComponent.writeObject(JComponent.java:3708)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.io.ObjectOutputStream.invokeObjectWriter(ObjectOutputStream.java
:1577)
        at java.io.ObjectOutputStream.outputObject(Compiled Code)
        at java.io.ObjectOutputStream.writeObject(Compiled Code)
        at java.io.ObjectOutputStream.outputArray(Compiled Code)
        at java.io.ObjectOutputStream.checkSubstitutableSpecialClasses(Compiled
Code)
        at java.io.ObjectOutputStream.writeObject(Compiled Code)
        at java.io.ObjectOutputStream.outputClassFields(Compiled Code)
        at java.io.ObjectOutputStream.defaultWriteObject(Compiled Code)
        at java.awt.Container.writeObject(Container.java:1465)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.io.ObjectOutputStream.invokeObjectWriter(ObjectOutputStream.java
:1577)
        at java.io.ObjectOutputStream.outputObject(Compiled Code)
        at java.io.ObjectOutputStream.writeObject(Compiled Code)
        at java.io.ObjectOutputStream.outputArray(Compiled Code)
        at java.io.ObjectOutputStream.checkSubstitutableSpecialClasses(Compiled
Code)
        at java.io.ObjectOutputStream.writeObject(Compiled Code)
        at java.io.ObjectOutputStream.outputClassFields(Compiled Code)
        at java.io.ObjectOutputStream.defaultWriteObject(Compiled Code)
        at java.awt.Container.writeObject(Container.java:1465)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.io.ObjectOutputStream.invokeObjectWriter(ObjectOutputStream.java
:1577)
        at java.io.ObjectOutputStream.outputObject(Compiled Code)
        at java.io.ObjectOutputStream.writeObject(Compiled Code)
        at java.io.ObjectOutputStream.outputArray(Compiled Code)
        at java.io.ObjectOutputStream.checkSubstitutableSpecialClasses(Compiled
Code)
        at java.io.ObjectOutputStream.writeObject(Compiled Code)
        at java.io.ObjectOutputStream.outputClassFields(Compiled Code)
        at java.io.ObjectOutputStream.defaultWriteObject(Compiled Code)
        at java.awt.Container.writeObject(Container.java:1465)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.io.ObjectOutputStream.invokeObjectWriter(ObjectOutputStream.java
:1577)
        at java.io.ObjectOutputStream.outputObject(Compiled Code)
        at java.io.ObjectOutputStream.writeObject(Compiled Code)
        at java.io.ObjectOutputStream.outputArray(Compiled Code)
        at java.io.ObjectOutputStream.checkSubstitutableSpecialClasses(Compiled
Code)
        at java.io.ObjectOutputStream.writeObject(Compiled Code)
        at java.io.ObjectOutputStream.outputClassFields(Compiled Code)
        at java.io.ObjectOutputStream.defaultWriteObject(Compiled Code)
        at java.awt.Container.writeObject(Container.java:1465)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.io.ObjectOutputStream.invokeObjectWriter(ObjectOutputStream.java
:1577)
        at java.io.ObjectOutputStream.outputObject(Compiled Code)
        at java.io.ObjectOutputStream.writeObject(Compiled Code)
        at java.io.ObjectOutputStream.outputArray(Compiled Code)
        at java.io.ObjectOutputStream.checkSubstitutableSpecialClasses(Compiled
Code)
        at java.io.ObjectOutputStream.writeObject(Compiled Code)
        at java.io.ObjectOutputStream.outputClassFields(Compiled Code)
        at java.io.ObjectOutputStream.defaultWriteObject(Compiled Code)
        at java.awt.Container.writeObject(Container.java:1465)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.io.ObjectOutputStream.invokeObjectWriter(ObjectOutputStream.java
:1577)
        at java.io.ObjectOutputStream.outputObject(Compiled Code)
        at java.io.ObjectOutputStream.writeObject(Compiled Code)
        at java.io.ObjectOutputStream.outputArray(Compiled Code)
        at java.io.ObjectOutputStream.checkSubstitutableSpecialClasses(Compiled
Code)
        at java.io.ObjectOutputStream.writeObject(Compiled Code)
        at java.io.ObjectOutputStream.outputClassFields(Compiled Code)
        at java.io.ObjectOutputStream.defaultWriteObject(Compiled Code)
        at java.awt.Container.writeObject(Container.java:1465)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.io.ObjectOutputStream.invokeObjectWriter(ObjectOutputStream.java
:1577)
        at java.io.ObjectOutputStream.outputObject(Compiled Code)
        at java.io.ObjectOutputStream.writeObject(Compiled Code)
        at SerialTest.test(SerialTest.java:60)
        at SerialTest.main(SerialTest.java:48)
(fail): 1
bae-chul.kim@eng 1998-08-10
=======================================

Here is an update to this bug. There seems to be a different exception from the ones listed. It would be nice to have this fixed. Here's the sample program to reproduce the bug.

-------------------------------- Cut Here ---------------------------------
import javax.swing.*;
import java.io.*;

public class TestSerialize {

    private JColorChooser chooser;

    public static void main(String[] args) {
        new TestSerialize();
    }

    public TestSerialize() {
        chooser = new JColorChooser();

        try {
            serializeAndDeserialize(chooser);
        } catch(Exception e) {
            e.printStackTrace();
        }
    }

    private Object serializeAndDeserialize(Object toWrite)
        throws ClassNotFoundException, IOException {

        FileOutputStream fos = new FileOutputStream("cereal.dat");
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        oos.writeObject(toWrite);
        oos.flush();
        fos.close();

        FileInputStream fis = new FileInputStream(System.getProperty
            ("resultsdir") +
            File.separator + "cereal.dat");
        ObjectInputStream ois = new ObjectInputStream(fis);
        Object retVal = ois.readObject();
        fis.close();

        return retVal;
    }
}
-------------------------------- Cut Here ---------------------------------

java.io.NotSerializableException: javax.swing.colorchooser.DefaultHSBChooserPanel$HueImage
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1057)
        at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1333)
        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1305)
        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1248)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1055)
        at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1227)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1053)
        at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1333)
        at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:370)
        at java.awt.Container.writeObject(Container.java:2536)
        at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:28)
        at java.lang.reflect.Method.invoke(Method.java:327)
        at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:783)
        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1297)
        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1248)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1055)
        at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1227)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1053)
        at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1333)
        at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:370)
        at java.awt.Container.writeObject(Container.java:2536)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:42)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:28)
        at java.lang.reflect.Method.invoke(Method.java:327)
        at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:783)
        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1297)
        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1248)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1055)
        at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1227)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1053)
        at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1333)
        at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:370)
        at java.awt.Container.writeObject(Container.java:2536)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:42)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:28)
        at java.lang.reflect.Method.invoke(Method.java:327)
        at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:783)
        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1297)
        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1248)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1055)
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:281)
        at TestSerialize.serializeAndDeserialize(TestSerialize.java:27)
        at TestSerialize.<init>(TestSerialize.java:16)
        at TestSerialize.main(TestSerialize.java:9)


###@###.### 2001-11-15
============================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b19
14-06-2004

EVALUATION Rich, any idea why something would be holding a reference to the tooltip manager? I grepped through the colochooser package and the basic package and didn't find anything suspicious. steve.wilson@eng 1998-08-11 i modified the TooltipManager to implement the seriailizable interface. the current error is coming now back from the color chooser: java SerialTest java.io.NotSerializableException: javax.swing.colorchooser.JIntegerTextField$ValueDelta at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java) at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java) at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java) at java.util.Hashtable.writeObject(Hashtable.java) at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java) at java.util.Hashtable.writeObject(Hashtable.java) at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java) at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java) at javax.swing.JComponent.writeObject(JComponent.java:3732) at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java) richard.schiavi@Eng 1998-10-13 Amy, this got cleared of responsible engineer and has been sitting around since for a while. I'm reassigning to you as I think you recently fixed this problem (TooltipManager serialization) but don't know the bug. scott.violet@eng 1999-09-15 The serialization failure is now the following with kestrel-H: java.io.NotSerializableException: javax.swing.plaf.basic.BasicTextUI$UpdateHandler at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1124) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:362) at java.io.ObjectOutputStream.outputClassFields(ObjectOutputStream.java:1774) at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:473) at java.awt.Container.writeObject(Container.java:1859) which leads me to believe the UI isn't being properly disconnected for the colorchooser. amy.fowler@Eng 1999-10-05 Name: ibR10256 Date: 08/21/2003 JColorChooser couldn't be serialized because of the two palette images which are one of the members of DefaultHSBChooserPanel. Exceptions were thrown because the HSBImage and Image classes didn't implement Serializable (HSBImage inner class is a substitution for the AbstractHSBImage, HueImage,BrightnessImage, SaturationImage, SaturationBrightnessImage, HueSaturationImage inner classes which were defined and used formerly in DefaultHSBChooserPanel, and thus produced the exceptions included in some of the previous evaluations). There seem to be no reasons to serialize these images as they are re-created anyway in DefaultHSBChooserPanel.initializePalettesIfNecessary() during deserialization as a result of JColorChooser.updateUI() call, therefore they can be made transient. ======================================================================
11-06-2004

SUGGESTED FIX Name: ibR10256 Date: 08/21/2003 *** /export1/iib/tiger/webrev/src/share/classes/javax/swing/colorchooser/DefaultHSBChooserPanel.java- Thu Aug 21 12:27:33 2003 --- DefaultHSBChooserPanel.java Mon Aug 18 14:12:02 2003 *************** *** 1,5 **** /* ! * @(#)DefaultHSBChooserPanel.java 1.23 03/07/23 * * Copyright 2003 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. --- 1,5 ---- /* ! * @(#)DefaultHSBChooserPanel.java 1.24 03/08/18 * * Copyright 2003 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. *************** *** 17,23 **** /** * Implements the default HSB Color chooser * ! * @version 1.23 07/23/03 * @author Tom Santos * @author Steve Wilson * @author Mark Davidson --- 17,23 ---- /** * Implements the default HSB Color chooser * ! * @version 1.24 08/18/03 * @author Tom Santos * @author Steve Wilson * @author Mark Davidson *************** *** 25,35 **** */ class DefaultHSBChooserPanel extends AbstractColorChooserPanel implements ChangeListener, HierarchyListener { ! private HSBImage palette; ! private HSBImage sliderPalette; ! private Image paletteImage; ! private Image sliderPaletteImage; private JSlider slider; private JSpinner hField; --- 25,35 ---- */ class DefaultHSBChooserPanel extends AbstractColorChooserPanel implements ChangeListener, HierarchyListener { ! private transient HSBImage palette; ! private transient HSBImage sliderPalette; ! private transient Image paletteImage; ! private transient Image sliderPaletteImage; private JSlider slider; private JSpinner hField; ======================================================================
11-06-2004