Other |
---|
tbdUnresolved |
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
Expression.getValue(Expression.java:101) at java.beans.Encoder.getValue(Encoder.java:84) at java.beans.Encoder.get(Encoder.java:186) at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:9 7) 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:363) at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:1 00) 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:326) at java.beans.DefaultPersistenceDelegate.invokeStatement(DefaultPersiste nceDelegate.java:242) at java.beans.DefaultPersistenceDelegate.initBean(DefaultPersistenceDele gate.java:335) at java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDe legate.java:395) at java.beans.javax_swing_JFrame_PersistenceDelegate.initialize(MetaData .java:510) at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:1 03) 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:363) at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:1 00) 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:326) at java.beans.XMLEncoder.writeObject(XMLEncoder.java:253) at Junk.XML$1.windowClosing(XML.java:72) at java.awt.Window.processWindowEvent(Window.java:1102) at javax.swing.JFrame.processWindowEvent(JFrame.java:266) at java.awt.Window.processEvent(Window.java:1061) at java.awt.Component.dispatchEventImpl(Component.java:3598) at java.awt.Container.dispatchEventImpl(Container.java:1623) at java.awt.Window.dispatchEventImpl(Window.java:1585) at java.awt.Component.dispatchEvent(Component.java:3439) at java.awt.EventQueue.dispatchEvent(EventQueue.java:450) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh read.java:197) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre ad.java:150) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136) at java.awt.EventDispatchThread.run(EventDispatchThread.java:99) java.lang.Exception: discarding statement JFrame0.addWindowListener(XML$10); at java.beans.XMLEncoder.writeStatement(XMLEncoder.java:339) at java.beans.DefaultPersistenceDelegate.invokeStatement(DefaultPersiste nceDelegate.java:242) at java.beans.DefaultPersistenceDelegate.initBean(DefaultPersistenceDele gate.java:335) at java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDe legate.java:395) at java.beans.javax_swing_JFrame_PersistenceDelegate.initialize(MetaData .java:510) at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:1 03) 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:363) at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:1 00) 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:326) at java.beans.XMLEncoder.writeObject(XMLEncoder.java:253) at Junk.XML$1.windowClosing(XML.java:72) at java.awt.Window.processWindowEvent(Window.java:1102) at javax.swing.JFrame.processWindowEvent(JFrame.java:266) at java.awt.Window.processEvent(Window.java:1061) at java.awt.Component.dispatchEventImpl(Component.java:3598) at java.awt.Container.dispatchEventImpl(Container.java:1623) at java.awt.Window.dispatchEventImpl(Window.java:1585) at java.awt.Component.dispatchEvent(Component.java:3439) at java.awt.EventQueue.dispatchEvent(EventQueue.java:450) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh read.java:197) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre ad.java:150) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136) at java.awt.EventDispatchThread.run(EventDispatchThread.java:99) Reading java.lang.IllegalArgumentException: index == 4 Continuing ... REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import java.awt.*; import java.awt.event.*; import java.beans.*; import java.io.*; import javax.swing.*; public class OrderTest { public static void main(final String[] args) { final JFrame f = new JFrame("Boogers"); JPanel load = new JPanel(new GridLayout(2, 1, 0, 0)); JLabel label = new JLabel("Label:"); load.add(label); JTextField field = new JTextField("Text"); load.add(field); label.setLabelFor(field); label.setDisplayedMnemonicIndex(4); load.setBorder(BorderFactory.createEtchedBorder()); f.getContentPane().add(load); f.pack(); f.setLocation(100, 100); f.setVisible(true); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { try { f.setVisible(false); System.err.println("Writing"); OutputStream out = new BufferedOutputStream(new FileOutputStream(args[0])); XMLEncoder xmle = new XMLEncoder(out); ExceptionListener el = new ExceptionListener() { public void exceptionThrown(Exception e) { e.printStackTrace(); } //Ends method exceptionThrown }; xmle.setExceptionListener(el); xmle.writeObject(f); xmle.close(); f.dispose(); System.err.println("Reading"); InputStream in = new BufferedInputStream(new FileInputStream(args[0])); XMLDecoder xmld = new XMLDecoder(in); xmld.setExceptionListener(el); JFrame f2 = (JFrame)xmld.readObject(); xmld.close(); f2.setDefaultCloseOperation(f2.EXIT_ON_CLOSE); f2.setVisible(true); } catch (Exception e) { e.printStackTrace(); } //Ends } //Ends method windowClosing }); //Ends addWindowListener } //Ends method } ---------- END SOURCE ---------- (Review ID: 180482) ====================================================================== Name: rl43681 Date: 01/28/2003 FULL PRODUCT VERSION : java version "1.4.1_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01- b01) Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode) FULL OPERATING SYSTEM VERSION : Microsoft Windows 2000 [Version 5.00.2195] A DESCRIPTION OF THE PROBLEM : I was using the XMLEncoder & XMLDecoder to save some graphical beans (a JFrame with a few simple components added) and I noticed that while some of the properties of the components were order-dependant, they were not saved that way. For example, if you use JLabel.setDisplayedMnemonicIndex() before you use JLabel.setText(), you get an ArrayIndexOutOfBoundsException. The XMLEncoder stores the properties willy-nilly and so when you retrieve the object with a decoder, the displayedMnemonicIndex property gets set before the text property and you get the exception. STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : 1. Compile the sample code 2. Run it. 3. Observe the exceptions being thrown EXPECTED VERSUS ACTUAL BEHAVIOR : I would expect that either one of two things: 1. The beans would be able to indicate dependant properties in some manner, and the XMLEncoder would respect the dependancies. or 2. The beans specification would state (maybe it does, I don't know) that properties must be independant, and the swing beans would then implement their properties in such a manner that you can set the displayedMnemonicIndex before you set the text. ERROR MESSAGES/STACK TRACES THAT OCCUR : Writing java.lang.IllegalArgumentException: index == 4 at javax.swing.JLabel.setDisplayedMnemonicIndex(JLabel.java:548) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at java.beans.Statement.invoke(Statement.java:470) at java.beans.Statement.execute(Statement.java:119) at java.beans.Encoder.execute(Encoder.java:94) at java.beans.Encoder.writeStatement(Encoder.java:238) at java.beans.XMLEncoder.writeStatement(XMLEncoder.java:326) at java.beans.DefaultPersistenceDelegate.invokeStatement(DefaultPersiste nceDelegate.java:242) at java.beans.DefaultPersistenceDelegate.doProperty(DefaultPersistenceDe legate.java:236) at java.beans.DefaultPersistenceDelegate.initBean(DefaultPersistenceDele gate.java:254) at java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDe legate.java:395) at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:1 03) 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:363) at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:1 00) 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:326) at java.beans.DefaultPersistenceDelegate.invokeStatement(DefaultPersiste nceDelegate.java:242) at java.beans.java_awt_Container_PersistenceDelegate.initialize(MetaData .java:400) at java.beans.PersistenceDelegate.initialize(PersistenceDelegate.java:19 1) at java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDe legate.java:393) at java.beans.javax_swing_JComponent_PersistenceDelegate.initialize(Meta Data.java:587) at java.beans.PersistenceDelegate.initialize(PersistenceDelegate.java:19 1) at java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDe legate.java:393) at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:1 03) 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:363) at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:1 00) 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:326) at java.beans.DefaultPersistenceDelegate.invokeStatement(DefaultPersiste nceDelegate.java:242) at java.beans.java_awt_Container_PersistenceDelegate.initialize(MetaData .java:400) at java.beans.PersistenceDelegate.initialize(PersistenceDelegate.java:19 1) at java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDe legate.java:393) at java.beans.javax_swing_JComponent_PersistenceDelegate.initialize(Meta Data.java:587) at java.beans.PersistenceDelegate.initialize(PersistenceDelegate.java:19 1) at java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDe legate.java:393) at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:1 03) 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:363) at java.beans.DefaultPersistenceDelegate.doProperty(DefaultPersistenceDe legate.java:219) at java.beans.DefaultPersistenceDelegate.initBean(DefaultPersistenceDele gate.java:254) at java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDe legate.java:395) at java.beans.javax_swing_JFrame_PersistenceDelegate.initialize(MetaData .java:510) at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:1 03) 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:363) at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:1 00) 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:326) at java.beans.XMLEncoder.writeObject(XMLEncoder.java:253) at Junk.XML$1.windowClosing(XML.java:72) at java.awt.Window.processWindowEvent(Window.java:1102) at javax.swing.JFrame.processWindowEvent(JFrame.java:266) at java.awt.Window.processEvent(Window.java:1061) at java.awt.Component.dispatchEventImpl(Component.java:3598) at java.awt.Container.dispatchEventImpl(Container.java:1623) at java.awt.Window.dispatchEventImpl(Window.java:1585) at java.awt.Component.dispatchEvent(Component.java:3439) at java.awt.EventQueue.dispatchEvent(EventQueue.java:450) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh read.java:197) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre ad.java:150) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136) at java.awt.EventDispatchThread.run(EventDispatchThread.java:99) java.lang.Exception: discarding statement JLabel0.setDisplayedMnemonicIndex(Inte ger0); at java.beans.Encoder.execute(Encoder.java:98) at java.beans.Encoder.writeStatement(Encoder.java:238) at java.beans.XMLEncoder.writeStatement(XMLEncoder.java:326) at java.beans.DefaultPersistenceDelegate.invokeStatement(DefaultPersiste nceDelegate.java:242) at java.beans.DefaultPersistenceDelegate.doProperty(DefaultPersistenceDe legate.java:236) at java.beans.DefaultPersistenceDelegate.initBean(DefaultPersistenceDele gate.java:254) at java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDe legate.java:395) at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:1 03) 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:363) at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:1 00) 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:326) at java.beans.DefaultPersistenceDelegate.invokeStatement(DefaultPersiste nceDelegate.java:242) at java.beans.java_awt_Container_PersistenceDelegate.initialize(MetaData .java:400) at java.beans.PersistenceDelegate.initialize(PersistenceDelegate.java:19 1) at java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDe legate.java:393) at java.beans.javax_swing_JComponent_PersistenceDelegate.initialize(Meta Data.java:587) at java.beans.PersistenceDelegate.initialize(PersistenceDelegate.java:19 1) at java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDe legate.java:393) at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:1 03) 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:363) at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:1 00) 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:326) at java.beans.DefaultPersistenceDelegate.invokeStatement(DefaultPersiste nceDelegate.java:242) at java.beans.java_awt_Container_PersistenceDelegate.initialize(MetaData .java:400) at java.beans.PersistenceDelegate.initialize(PersistenceDelegate.java:19 1) at java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDe legate.java:393) at java.beans.javax_swing_JComponent_PersistenceDelegate.initialize(Meta Data.java:587) at java.beans.PersistenceDelegate.initialize(PersistenceDelegate.java:19 1) at java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDe legate.java:393) at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:1 03) 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:363) at java.beans.DefaultPersistenceDelegate.doProperty(DefaultPersistenceDe legate.java:219) at java.beans.DefaultPersistenceDelegate.initBean(DefaultPersistenceDele gate.java:254) at java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDe legate.java:395) at java.beans.javax_swing_JFrame_PersistenceDelegate.initialize(MetaData .java:510) at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:1 03) 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:363) at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:1 00) 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:326) at java.beans.XMLEncoder.writeObject(XMLEncoder.java:253) at Junk.XML$1.windowClosing(XML.java:72) at java.awt.Window.processWindowEvent(Window.java:1102) at javax.swing.JFrame.processWindowEvent(JFrame.java:266) at java.awt.Window.processEvent(Window.java:1061) at java.awt.Component.dispatchEventImpl(Component.java:3598) at java.awt.Container.dispatchEventImpl(Container.java:1623) at java.awt.Window.dispatchEventImpl(Window.java:1585) at java.awt.Component.dispatchEvent(Component.java:3439) at java.awt.EventQueue.dispatchEvent(EventQueue.java:450) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh read.java:197) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre ad.java:150) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136) at java.awt.EventDispatchThread.run(EventDispatchThread.java:99) java.lang.InstantiationException: Junk.XML$1 at java.lang.Class.newInstance0(Class.java:291) at java.lang.Class.newInstance(Class.java:259) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at java.beans.Statement.invoke(Statement.java:470) at java.beans.
|