Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4739044

LTP: XMLEncoder InstantiationException with JMenu

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 1.4.0, 1.4.1
    • client-libs
    • Cause Known
    • x86
    • linux, windows_nt, windows_2000

      Name: gm110360 Date: 08/29/2002


      FULL PRODUCT VERSION :
      java version "1.4.1-rc"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-rc-b19)
      Java HotSpot(TM) Client VM (build 1.4.1-rc-b19, mixed mode)

      FULL OPERATING SYSTEM VERSION :
      Microsoft Windows 2000 [Version 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      XMLEncoder on a JFrame containing a
      JMenu throws java.lang.InstantiationException
      javax.swing.PopupFactory$1

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1.run example code
      2.select Test menu
      3.close window with "close window" button

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Actual results: see description
      Expected: should finish without exceptions printing this 2
      lines:
      Starting
      Exiting
      Note, that step 2 in Reproduce is essential: without it the
      actual results are the same, as expected...

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Starting
      java.lang.InstantiationException: javax.swing.PopupFactory$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
      (DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:324)
              at java.beans.Statement.invoke(Statement.java:470)
              at java.beans.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:97)
              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: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:326)
              at java.beans.DefaultPersistenceDelegate.invokeStatement
      (DefaultPersistenceDelegate.java:242)
              at java.beans.DefaultPersistenceDelegate.initBean
      (DefaultPersistenceDelegate.java:335)
              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:363)
              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:326)
              at java.beans.XMLEncoder.writeObject(XMLEncoder.java:253)
              at persistence_test.TestApp.windowClosing(TestApp.java:62)
              at java.awt.AWTEventMulticaster.windowClosing
      (AWTEventMulticaster.java:287)
              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
      (EventDispatchThread.java:197)
              at java.awt.EventDispatchThread.pumpEventsForHierarchy
      (EventDispatchThread.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)
       Continuing ...
      java.lang.Exception: discarding statement TestApp0.addWindowListener
      (PopupFactory$10);
              at java.beans.XMLEncoder.writeStatement(XMLEncoder.java:339)
              at java.beans.DefaultPersistenceDelegate.invokeStatement
      (DefaultPersistenceDelegate.java:242)
              at java.beans.DefaultPersistenceDelegate.initBean
      (DefaultPersistenceDelegate.java:335)
              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:363)
              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:326)
              at java.beans.XMLEncoder.writeObject(XMLEncoder.java:253)
              at persistence_test.TestApp.windowClosing(TestApp.java:62)
              at java.awt.AWTEventMulticaster.windowClosing
      (AWTEventMulticaster.java:287)
              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
      (EventDispatchThread.java:197)
              at java.awt.EventDispatchThread.pumpEventsForHierarchy
      (EventDispatchThread.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)
       Continuing ...
      Exiting


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      /*
       * TestApp.java
       *
       * Created on August 11, 2002, 12:01 PM
       */

      package persistence_test;

      import javax.swing.*;
      import java.beans.*;
      import java.awt.*;
      import java.io.*;
      import java.awt.event.*;

      /**
       *
       * @author Administrator
       * @version 1.0
       */
      public class TestApp extends JFrame implements WindowListener, ExceptionListener
      {
          
          /** Creates new TestApp */
          public TestApp() {
              setDefaultCloseOperation(EXIT_ON_CLOSE);
              JMenuBar menuBar = new JMenuBar();
              setJMenuBar(menuBar);
              menuBar.add(new JMenu("Test"));
              addWindowListener(this);
              pack();
          }

          /**
          * @param args the command line arguments
          */
          public static void main (String args[]) {
              System.err.println("Starting");
              (new TestApp()).setVisible(true);
          }

          /**
           * This method is called when a recoverable exception has
           * been caught.
           *
           * @param e The exception that was caught.
           *
           */
          public void exceptionThrown(Exception e) {
                  e.printStackTrace(System.err);
                  System.err.println(" Continuing ...");
          }
          
          /**
           * Invoked when the user attempts to close the window
           * from the window's system menu. If the program does not
           * explicitly hide or dispose the window while processing
           * this event, the window close operation will be cancelled.
           */
          public void windowClosing(WindowEvent e) {
              XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(new
      ByteArrayOutputStream()));
              encoder.setExceptionListener(this);
              encoder.writeObject(this);
              System.err.println("Exiting");
          }
          
          /**
           * Invoked when the Window is set to be the active Window. Only a Frame or
           * a Dialog can be the active Window. The native windowing system may
           * denote the active Window or its children with special decorations, such
           * as a highlighted title bar. The active Window is always either the
           * focused Window, or the first Frame or Dialog that is an owner of the
           * focused Window.
           */
          public void windowActivated(WindowEvent e) {
          }
          
          /**
           * Invoked when a window is changed from a minimized
           * to a normal state.
           */
          public void windowDeiconified(WindowEvent e) {
          }
          
          /**
           * Invoked when a Window is no longer the active Window. Only a Frame or a
           * Dialog can be the active Window. The native windowing system may denote
           * the active Window or its children with special decorations, such as a
           * highlighted title bar. The active Window is always either the focused
           * Window, or the first Frame or Dialog that is an owner of the focused
           * Window.
           */
          public void windowDeactivated(WindowEvent e) {
          }
          
          /**
           * Invoked when a window is changed from a normal to a
           * minimized state. For many platforms, a minimized window
           * is displayed as the icon specified in the window's
           * iconImage property.
           * @see java.awt.Frame#setIconImage
           */
          public void windowIconified(WindowEvent e) {
          }
          
          /**
           * Invoked when a window has been closed as the result
           * of calling dispose on the window.
           */
          public void windowClosed(WindowEvent e) {
          }
          
          /**
           * Invoked the first time a window is made visible.
           */
          public void windowOpened(WindowEvent e) {
          }
      }

      ---------- END SOURCE ----------
      (Review ID: 163776)
      ======================================================================

            malenkov Sergey Malenkov (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: