-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
1.4.0
-
generic
-
generic
Description:
------------
The following code is going through all the beans in the JDK, instantiates them, persists them to XML file and then recrates them. While running this application with build87 of merlin, I am getting a StackOverFlow error. The same application is running fine with build84, but it is failing with b85, b86 and b87 on all the operating systems.
The StackOverflow output is there in a file "StackTrace.txt" as an attachment.
********************************************************************************
Code:
----
import java.beans.*;
import java.io.*;
import java.util.*;
import java.lang.reflect.*;
public class BeanBag
{
private Vector allTheBeans;
private Object beanObject;
/** Creates new BeanBag */
public BeanBag()
{
allTheBeans = new Vector();
String a[]={"JCheckBox","JPasswordField","JTextArea","JMenuItem","JScrollPane","JRadioButtonMenuItem","JSplitPane","JList","JCheckBoxMenuItem","JPanel","JTabbedPane","JSeparator","JProgressBar","JScrollBar","JRadioButton","JDialog","JOptionPane","JComboBox","JTextField","JButton","JToolBar","JWindow","JFrame","JApplet","JMenu","JPopupMenu","JTable","JMenuBar","JTree","JLabel","JSlider","JTextPane","JEditorPane","JToggleButton","JInternalFrame"};
for(int i=0;i<a.length;i++)
{
allTheBeans.add("javax.swing."+ a[i]);
}
try
{
for (Iterator it = allTheBeans.iterator(); it.hasNext();)
{
String thisClassName = (String) it.next();
archive(thisClassName, (thisClassName + ".xml"));
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
/** this method archives the bean */
public void archive(String bean, String archFileName)
{
try
{
// create an instance of this type of class
Class beanClass = Class.forName(bean);
this.beanObject = beanClass.newInstance();
XMLEncoder enc = new XMLEncoder(new BufferedOutputStream(
new FileOutputStream(archFileName)));
enc.writeObject(beanObject);
enc.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
public static void main(String args[])
{
new BeanBag();
}
}
********************************************************************************
To Reproduce:
-------------
1. Copy the code and save it as "BeanBag.java".
2. Set the path to build87 of merlin.
3. Compile it
javasoft7%/home/ls121046/test % javac BeanBag.java
4. Run it using "java BeanBag"
Here is a part of the stack which is being thrown:
=======
java.lang.InstantiationException: javax.swing.plaf.metal.MetalSplitPaneDivider
Continuing ...
java.lang.Exception: discarding statement JSplitPane0.add(MetalSplitPaneDivider0);
Continuing ...
Exception in thread "main" java.lang.StackOverflowError
at java.io.Writer.write(Writer.java:129)
at java.io.PrintStream.write(PrintStream.java:306)
at java.io.PrintStream.print(PrintStream.java:465)
at java.io.PrintStream.println(PrintStream.java:602)
at java.lang.Throwable.printStackTrace(Throwable.java:464)
at java.lang.Throwable.printStackTrace(Throwable.java:454)
at java.beans.MetaData.getBeanInfo(MetaData.java:914)
at java.beans.DefaultPersistenceDelegate.isTransient(DefaultPersistenceDelegate.java:195)
at java.beans.DefaultPersistenceDelegate.doProperty(DefaultPersistenceDelegate.java:217)
at java.beans.DefaultPersistenceDelegate.initBean(DefaultPersistenceDelegate.java:257)
at java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDelegate.java:398)
at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:106)
at java.beans.Encoder.writeObject(Encoder.java:58)
at java.beans.XMLEncoder.writeObject(XMLEncoder.java:253)
at java.beans.Encoder.writeExpression(Encoder.java:263)
at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:354)
=================
------------
The following code is going through all the beans in the JDK, instantiates them, persists them to XML file and then recrates them. While running this application with build87 of merlin, I am getting a StackOverFlow error. The same application is running fine with build84, but it is failing with b85, b86 and b87 on all the operating systems.
The StackOverflow output is there in a file "StackTrace.txt" as an attachment.
********************************************************************************
Code:
----
import java.beans.*;
import java.io.*;
import java.util.*;
import java.lang.reflect.*;
public class BeanBag
{
private Vector allTheBeans;
private Object beanObject;
/** Creates new BeanBag */
public BeanBag()
{
allTheBeans = new Vector();
String a[]={"JCheckBox","JPasswordField","JTextArea","JMenuItem","JScrollPane","JRadioButtonMenuItem","JSplitPane","JList","JCheckBoxMenuItem","JPanel","JTabbedPane","JSeparator","JProgressBar","JScrollBar","JRadioButton","JDialog","JOptionPane","JComboBox","JTextField","JButton","JToolBar","JWindow","JFrame","JApplet","JMenu","JPopupMenu","JTable","JMenuBar","JTree","JLabel","JSlider","JTextPane","JEditorPane","JToggleButton","JInternalFrame"};
for(int i=0;i<a.length;i++)
{
allTheBeans.add("javax.swing."+ a[i]);
}
try
{
for (Iterator it = allTheBeans.iterator(); it.hasNext();)
{
String thisClassName = (String) it.next();
archive(thisClassName, (thisClassName + ".xml"));
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
/** this method archives the bean */
public void archive(String bean, String archFileName)
{
try
{
// create an instance of this type of class
Class beanClass = Class.forName(bean);
this.beanObject = beanClass.newInstance();
XMLEncoder enc = new XMLEncoder(new BufferedOutputStream(
new FileOutputStream(archFileName)));
enc.writeObject(beanObject);
enc.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
public static void main(String args[])
{
new BeanBag();
}
}
********************************************************************************
To Reproduce:
-------------
1. Copy the code and save it as "BeanBag.java".
2. Set the path to build87 of merlin.
3. Compile it
javasoft7%/home/ls121046/test % javac BeanBag.java
4. Run it using "java BeanBag"
Here is a part of the stack which is being thrown:
=======
java.lang.InstantiationException: javax.swing.plaf.metal.MetalSplitPaneDivider
Continuing ...
java.lang.Exception: discarding statement JSplitPane0.add(MetalSplitPaneDivider0);
Continuing ...
Exception in thread "main" java.lang.StackOverflowError
at java.io.Writer.write(Writer.java:129)
at java.io.PrintStream.write(PrintStream.java:306)
at java.io.PrintStream.print(PrintStream.java:465)
at java.io.PrintStream.println(PrintStream.java:602)
at java.lang.Throwable.printStackTrace(Throwable.java:464)
at java.lang.Throwable.printStackTrace(Throwable.java:454)
at java.beans.MetaData.getBeanInfo(MetaData.java:914)
at java.beans.DefaultPersistenceDelegate.isTransient(DefaultPersistenceDelegate.java:195)
at java.beans.DefaultPersistenceDelegate.doProperty(DefaultPersistenceDelegate.java:217)
at java.beans.DefaultPersistenceDelegate.initBean(DefaultPersistenceDelegate.java:257)
at java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDelegate.java:398)
at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:106)
at java.beans.Encoder.writeObject(Encoder.java:58)
at java.beans.XMLEncoder.writeObject(XMLEncoder.java:253)
at java.beans.Encoder.writeExpression(Encoder.java:263)
at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:354)
=================
- duplicates
-
JDK-4525285 JCK1.4: api/java_beans/XMLDecoder/index.html#read throws StackOverflowError
-
- Closed
-