Name: gm110360 Date: 04/11/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 :
Windows 98 [version 4.10.1998]
A DESCRIPTION OF THE PROBLEM :
Getting an arrayIndexOutOfBoundsException when using
XMLEncoder on the following :
Trying to encode a JDesktopPane which has one JInternalFrame
which has a JPanel which has a JScrollPane holding a JTable.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. run sample code
2. select encode on the menu bar
3.
EXPECTED VERSUS ACTUAL BEHAVIOR :
see description
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.ArrayIndexOutOfBoundsException
at
java.beans.DefaultPersistenceDelegate.initBean(DefaultPersistenceDelegate.java:3
40)
at
java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDelegate.java
:395)
at
java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:103)
at java.beans.Encoder.writeObject(Encoder.java:55)
at java.beans.XMLEncoder.writeObject(XMLEncoder.java:250)
at java.beans.Encoder.writeExpression(Encoder.java:260)
at java.beans.XMLEncoder.writeExpressionException thrown =
java.lang.ArrayIndexOutOfBoundsException
(XMLEncoder.java:351)
at
java.beans.DefaultPersistenceDelegate.doProperty(DefaultPersistenceDelegate.java
:219)
at
java.beans.DefaultPersistenceDelegate.initBean(DefaultPersistenceDelegate.java:2
54)
at
java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDelegate.java
:395)
at
java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:103)
at java.beans.Encoder.writeObject(Encoder.java:55)
at java.beans.XMLEncoder.writeObject(XMLEncoder.java:250)
at java.beans.Encoder.writeExpression(Encoder.java:260)
at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:351)
at
java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:100)
at java.beans.Encoder.writeObject(Encoder.java:55)
at java.beans.XMLEncoder.writeObject(XMLEncoder.java:250)
at java.beans.Encoder.writeObject1(Encoder.java:192)
at java.beans.Encoder.cloneStatement(Encoder.java:205)
at java.beans.Encoder.writeStatement(Encoder.java:236)
at java.beans.XMLEncoder.writeStatement(XMLEncoder.java:320)
at
java.beans.DefaultPersistenceDelegate.invokeStatement(DefaultPersistenceDelegate
.java:242)
at
java.beans.java_awt_Container_PersistenceDelegate.initialize(MetaData.java:378)
at
java.beans.PersistenceDelegate.initialize(PersistenceDelegate.java:191)
at
java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDelegate.java
:393)
at
java.beans.javax_swing_JComponent_PersistenceDelegate.initialize(MetaData.java:5
65)
at
java.beans.PersistenceDelegate.initialize(PersistenceDelegate.java:191)
at
java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDelegate.java
:393)
at
java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:103)
at java.beans.Encoder.writeObject(Encoder.java:55)
at java.beans.XMLEncoder.writeObject(XMLEncoder.java:250)
at java.beans.Encoder.writeExpression(Encoder.java:260)
at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:351)
at
java.beans.DefaultPersistenceDelegate.doProperty(DefaultPersistenceDelegate.java
:219)
at
java.beans.DefaultPersistenceDelegate.initBean(DefaultPersistenceDelegate.java:2
54)
at
java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDelegate.java
:395)
at
java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:103)
at java.beans.Encoder.writeObject(Encoder.java:55)
at java.beans.XMLEncoder.writeObject(XMLEncoder.java:250)
at java.beans.Encoder.writeExpression(Encoder.java:260)
at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:351)
at
java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:100)
at java.beans.Encoder.writeObject(Encoder.java:55)
at java.beans.XMLEncoder.writeObject(XMLEncoder.java:250)
at java.beans.Encoder.writeObject1(Encoder.java:192)
at java.beans.Encoder.cloneStatement(Encoder.java:205)
at java.beans.Encoder.writeStatement(Encoder.java:236)
at java.beans.XMLEncoder.writeStatement(XMLEncoder.java:320)
at
java.beans.DefaultPersistenceDelegate.invokeStatement(DefaultPersistenceDelegate
.java:242)
at
java.beans.java_awt_Container_PersistenceDelegate.initialize(MetaData.java:378)
at
java.beans.PersistenceDelegate.initialize(PersistenceDelegate.java:191)
at
java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDelegate.java
:393)
at
java.beans.javax_swing_JComponent_PersistenceDelegate.initialize(MetaData.java:5
65)
at
java.beans.PersistenceDelegate.initialize(PersistenceDelegate.java:191)
at
java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDelegate.java
:393)
at
java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:103)
at java.beans.Encoder.writeObject(Encoder.java:55)
at java.beans.XMLEncoder.writeObject(XMLEncoder.java:250)
at java.beans.Encoder.writeExpression(Encoder.java:260)
at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:351)
at
java.beans.DefaultPersistenceDelegate.doProperty(DefaultPersistenceDelegate.java
:219)
at
java.beans.DefaultPersistenceDelegate.initBean(DefaultPersistenceDelegate.java:2
54)
at
java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDelegate.java
:395)
at
java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:103)
at java.beans.Encoder.writeObject(Encoder.java:55)
at java.beans.XMLEncoder.writeObject(XMLEncoder.java:250)
at java.beans.Encoder.writeExpression(Encoder.java:260)
at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:351)
at
java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:100)
at java.beans.Encoder.writeObject(Encoder.java:55)
at java.beans.XMLEncoder.writeObject(XMLEncoder.java:250)
at java.beans.Encoder.writeObject1(Encoder.java:192)
at java.beans.Encoder.cloneStatement(Encoder.java:205)
at java.beans.Encoder.writeStatement(Encoder.java:236)
at java.beans.XMLEncoder.writeStatement(XMLEncoder.java:320)
at
java.beans.DefaultPersistenceDelegate.invokeStatement(DefaultPersistenceDelegate
.java:242)
at
java.beans.java_awt_Container_PersistenceDelegate.initialize(MetaData.java:378)
at
java.beans.PersistenceDelegate.initialize(PersistenceDelegate.java:191)
at
java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDelegate.java
:393)
at
java.beans.javax_swing_JComponent_PersistenceDelegate.initialize(MetaData.java:5
65)
at
java.beans.PersistenceDelegate.initialize(PersistenceDelegate.java:191)
at
java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDelegate.java
:393)
at
java.beans.PersistenceDelegate.initialize(PersistenceDelegate.java:191)
at
java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDelegate.java
:393)
at
java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:103)
at java.beans.Encoder.writeObject(Encoder.java:55)
at java.beans.XMLEncoder.writeObject(XMLEncoder.java:250)
at java.beans.Encoder.writeExpression(Encoder.java:260)
at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:351)
at
java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:100)
at java.beans.Encoder.writeObject(Encoder.java:55)
at java.beans.XMLEncoder.writeObject(XMLEncoder.java:250)
at java.beans.Encoder.writeObject1(Encoder.java:192)
at java.beans.Encoder.cloneStatement(Encoder.java:205)
at java.beans.Encoder.writeStatement(Encoder.java:236)
at java.beans.XMLEncoder.writeStatement(XMLEncoder.java:320)
at java.beans.XMLEncoder.writeObject(XMLEncoder.java:253)
at testxmlencoder.TestXMLEncoder.encodeDesktop(TestXMLEncoder.java:113)
at
testxmlencoder.TestXMLEncoder$1.actionPerformed(TestXMLEncoder.java:82)
at
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1767)
at
javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.ja
va:1820)
at
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:419)
at
javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)
at javax.swing.AbstractButton.doClick(AbstractButton.java:289)
at
javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1092)
at
javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseReleased(BasicMenu
ItemUI.java:932)
at java.awt.Component.processMouseEvent(Component.java:5021)
at java.awt.Component.processEvent(Component.java:4818)
at java.awt.Container.processEvent(Container.java:1380)
at java.awt.Component.dispatchEventImpl(Component.java:3526)
at java.awt.Container.dispatchEventImpl(Container.java:1437)
at java.awt.Component.dispatchEvent(Component.java:3367)
at
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3214)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2929)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2859)
at java.awt.Container.dispatchEventImpl(Container.java:1423)
at java.awt.Window.dispatchEventImpl(Window.java:1566)
at java.awt.Component.dispatchEvent(Component.java:3367)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:445)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:1
90)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:144
)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:130)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:98)
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package testxmlencoder;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.beans.*;
import javax.swing.*;
public class TestXMLEncoder implements ExceptionListener {
JFrame frame;
JDesktopPane desktop;
JPanel panel;
public TestXMLEncoder() {
frame = new JFrame("JFrame");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
panel = new JPanel();
panel.setLayout(new BorderLayout());
JMenuBar menuBar = new JMenuBar();
menuBar.add(createXMLMenu());
JTable table = new JTable(50, 50);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
table.setCellSelectionEnabled(true);
table.setRowSelectionInterval(0,0);
table.setColumnSelectionInterval(0,0);
JScrollPane scrollPane = new JScrollPane(table);
JInternalFrame internalFrame = new JInternalFrame("internal frame",
true, true, true, true);
internalFrame.getContentPane().add(scrollPane);
internalFrame.setSize( 400, 200);
internalFrame.setVisible(true);
desktop = new JDesktopPane();
desktop.add(internalFrame);
panel.add(menuBar, BorderLayout.NORTH);
panel.add(desktop, BorderLayout.CENTER);
frame.getContentPane().add(panel);
frame.setBounds(10, 10, 600, 304);
frame.setVisible(true);
} // constructor
public static void main(String[] args) {
new TestXMLEncoder();
}
public void exceptionThrown(Exception excp) {
System.out.println("Exception thrown = " + excp);
excp.printStackTrace();
}
protected JMenu createXMLMenu() {
JMenu menu;
JMenuItem item;
AbstractAction encodeAction;
AbstractAction decodeAction;
menu = new JMenu("File");
encodeAction = new AbstractAction("Encode") {
public void actionPerformed(ActionEvent e) {
try {
encodeDesktop();
} catch (FileNotFoundException excp) {
System.out.println("encode file not found");
};
} // actionPerformed
}; // fileEncodeAction AbstractAction
decodeAction = new AbstractAction("Decode") {
public void actionPerformed(ActionEvent e) {
try {
decodeDesktop();
} catch (FileNotFoundException excp) {
System.out.println("decode file not found");
};
} // actionPerformed
}; // fileDecodeAction AbstractAction
menu.add(encodeAction);
menu.add(decodeAction);
return menu;
} // createFileMenu
public void encodeDesktop() throws FileNotFoundException {
XMLEncoder e = new XMLEncoder(
new BufferedOutputStream(
new FileOutputStream("Test.xml")));
e.setExceptionListener(this);
e.writeObject(desktop);
e.close();
panel.remove(desktop);
panel.revalidate();
panel.repaint();
desktop = null;
}
public void decodeDesktop() throws FileNotFoundException {
XMLDecoder d = new XMLDecoder(
new BufferedInputStream(
new FileInputStream("Test.xml")));
Object result = d.readObject();
d.close();
desktop = (JDesktopPane)result;
JInternalFrame frames[] = desktop.getAllFrames();
for (int i = 0; i < frames.length; i++) {
frames[i].setVisible(true);
frames[i].setSize( 400, 200);
}
panel.add(desktop, BorderLayout.CENTER);
panel.revalidate();
panel.repaint();
}
} // class TestXMLEncoder
---------- END SOURCE ----------
(Review ID: 145029)
======================================================================