-
Bug
-
Resolution: Fixed
-
P3
-
1.3.0
-
kestrel
-
generic, x86, sparc
-
generic, solaris_7, windows_nt
-
Verified
Observed on Solaris Kestrel Beta (build M). Update: Still observed with build J.
javax.swing.ImageIcon$AccessibleImageIcon throws a java.io.NotSerializableException in *JOptionPane*
[updated by raj.premkumar@eng 1999-10-13]
Name: sg39081 Date: 09/01/99
When you try to serialize a JLabel or whatever with a ImageIcon in it, the following exception is thrown:
java.io.NotSerializableException: javax.swing.ImageIcon$AccessibleImageIcon
at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1123)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:361)
at java.io.ObjectOutputStream.outputClassFields(ObjectOutputStream.java:1773)
at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:472)
at javax.swing.JLabel.writeObject(JLabel.java:800)
at java.lang.reflect.Method.invoke(Native Method)
at java.io.ObjectOutputStream.invokeObjectWriter(ObjectOutputStream.java:1810)
at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1185)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:361)
at java.io.ObjectOutputStream.outputArray(ObjectOutputStream.java:1073)
at java.io.ObjectOutputStream.checkSubstitutableSpecialClasses(ObjectOutputStream.java:451)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:356)
at java.io.ObjectOutputStream.outputClassFields(ObjectOutputStream.java:1773)
at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:472)
at java.awt.Container.writeObject(Container.java:1857)
at java.lang.reflect.Method.invoke(Native Method)
at java.io.ObjectOutputStream.invokeObjectWriter(ObjectOutputStream.java:1810)
at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1185)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:361)
at com.teamenergy.products.gk.LabelDemo.actionPerformed(LabelDemo.java:42)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1230)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1265)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:378)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:250)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:238)
at java.awt.Component.processMouseEvent(Component.java:3612)
at java.awt.Component.processEvent(Component.java:3441)
at java.awt.Container.processEvent(Container.java:1253)
at java.awt.Component.dispatchEventImpl(Component.java:2529)
at java.awt.Container.dispatchEventImpl(Container.java:1302)
at java.awt.Component.dispatchEvent(Component.java:2443)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2504)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2288)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2191)
at java.awt.Container.dispatchEventImpl(Container.java:1289)
at java.awt.Window.dispatchEventImpl(Window.java:854)
at java.awt.Component.dispatchEvent(Component.java:2443)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:302)
at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:95)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:86)
Here is some source code to demonstrate:
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
/**
* Display a JLabel with an ImageIcon in a JPanel (although it doesnt matter
* what it is displayed in) and include a save button.
* When the button is pressed, attempt to serialize the JPanel containing the
* JLabel. It dies bigtime.
*/
public class LabelDemo extends JFrame
implements ActionListener
{
private static final String FILENAME = "somegif.gif";
private JPanel mainPanel;
private JButton saveButton;
public LabelDemo()
{
super("LabelDemo");
mainPanel = new JPanel();
mainPanel.add(new JLabel(new ImageIcon(FILENAME)));
saveButton = new JButton("Save");
saveButton.addActionListener(this);
getContentPane().add(BorderLayout.CENTER, mainPanel);
getContentPane().add(BorderLayout.SOUTH, saveButton);
}
public void actionPerformed(ActionEvent e)
{
try
{
System.out.println("About to serialize");
ObjectOutputStream os = new ObjectOutputStream(
new FileOutputStream("someFile"));
os.writeObject(mainPanel);
os.close();
}
catch (IOException ex)
{ ex.printStackTrace();; }
}
public static void main(String[] args) {
JFrame frame = new LabelDemo();
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
frame.pack();
frame.setVisible(true);
}
}
PLEASE fix this! Serializing a JEditorPane with embedded JTables and JLabels with ImageIcons is impossible at the moment.
(Review ID: 94582)
======================================================================
Name: skT88420 Date: 09/07/99
ImageIcon is not serializable anymore when switching from
JDK 1.2 to 1.3 (beta)
Exception:
java.io.NotSerializableException: javax.swing.ImageIcon$AccessibleImageIcon
(Review ID: 94795)
======================================================================
javax.swing.ImageIcon$AccessibleImageIcon throws a java.io.NotSerializableException in *JOptionPane*
[updated by raj.premkumar@eng 1999-10-13]
Name: sg39081 Date: 09/01/99
When you try to serialize a JLabel or whatever with a ImageIcon in it, the following exception is thrown:
java.io.NotSerializableException: javax.swing.ImageIcon$AccessibleImageIcon
at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1123)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:361)
at java.io.ObjectOutputStream.outputClassFields(ObjectOutputStream.java:1773)
at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:472)
at javax.swing.JLabel.writeObject(JLabel.java:800)
at java.lang.reflect.Method.invoke(Native Method)
at java.io.ObjectOutputStream.invokeObjectWriter(ObjectOutputStream.java:1810)
at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1185)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:361)
at java.io.ObjectOutputStream.outputArray(ObjectOutputStream.java:1073)
at java.io.ObjectOutputStream.checkSubstitutableSpecialClasses(ObjectOutputStream.java:451)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:356)
at java.io.ObjectOutputStream.outputClassFields(ObjectOutputStream.java:1773)
at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:472)
at java.awt.Container.writeObject(Container.java:1857)
at java.lang.reflect.Method.invoke(Native Method)
at java.io.ObjectOutputStream.invokeObjectWriter(ObjectOutputStream.java:1810)
at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1185)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:361)
at com.teamenergy.products.gk.LabelDemo.actionPerformed(LabelDemo.java:42)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1230)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1265)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:378)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:250)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:238)
at java.awt.Component.processMouseEvent(Component.java:3612)
at java.awt.Component.processEvent(Component.java:3441)
at java.awt.Container.processEvent(Container.java:1253)
at java.awt.Component.dispatchEventImpl(Component.java:2529)
at java.awt.Container.dispatchEventImpl(Container.java:1302)
at java.awt.Component.dispatchEvent(Component.java:2443)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2504)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2288)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2191)
at java.awt.Container.dispatchEventImpl(Container.java:1289)
at java.awt.Window.dispatchEventImpl(Window.java:854)
at java.awt.Component.dispatchEvent(Component.java:2443)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:302)
at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:95)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:86)
Here is some source code to demonstrate:
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
/**
* Display a JLabel with an ImageIcon in a JPanel (although it doesnt matter
* what it is displayed in) and include a save button.
* When the button is pressed, attempt to serialize the JPanel containing the
* JLabel. It dies bigtime.
*/
public class LabelDemo extends JFrame
implements ActionListener
{
private static final String FILENAME = "somegif.gif";
private JPanel mainPanel;
private JButton saveButton;
public LabelDemo()
{
super("LabelDemo");
mainPanel = new JPanel();
mainPanel.add(new JLabel(new ImageIcon(FILENAME)));
saveButton = new JButton("Save");
saveButton.addActionListener(this);
getContentPane().add(BorderLayout.CENTER, mainPanel);
getContentPane().add(BorderLayout.SOUTH, saveButton);
}
public void actionPerformed(ActionEvent e)
{
try
{
System.out.println("About to serialize");
ObjectOutputStream os = new ObjectOutputStream(
new FileOutputStream("someFile"));
os.writeObject(mainPanel);
os.close();
}
catch (IOException ex)
{ ex.printStackTrace();; }
}
public static void main(String[] args) {
JFrame frame = new LabelDemo();
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
frame.pack();
frame.setVisible(true);
}
}
PLEASE fix this! Serializing a JEditorPane with embedded JTables and JLabels with ImageIcons is impossible at the moment.
(Review ID: 94582)
======================================================================
Name: skT88420 Date: 09/07/99
ImageIcon is not serializable anymore when switching from
JDK 1.2 to 1.3 (beta)
Exception:
java.io.NotSerializableException: javax.swing.ImageIcon$AccessibleImageIcon
(Review ID: 94795)
======================================================================