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

Kestrel-Swing NotSerializableException at BasicGraphicsUtils.isLeftToRight

    XMLWordPrintable

Details

    • hopper
    • sparc
    • solaris_7
    • Verified

    Description

      Launching, running, then saving the attached applet causes a NotSerializableException at BasicGraphicsUtils.isLeftToRight. This occurred on Solaris 2.7 with Kestrel-fcs-V.

      Steps to Reproduce:
      1) Using the attached applet, run it with appletviewer.
      2) Play with the applet, press the buttons, use menus, etc.
      3) Select "Save..." from the "Applet" menu.
      RESULT: In the console window the following exception is thrown:

      in appletSave: java.io.NotSerializableException: java.lang.Thread
      java.lang.NullPointerException at javax.swing.plaf.basic.BasicGraphicsUtils.isLeftToRight(BasicGraphicsUtils.java:300) at javax.swing.plaf.basic.BasicMenuItemUI.layoutMenuItem(BasicMenuItemUI.java:753)
         at javax.swing.plaf.basic.BasicMenuItemUI.getPreferredMenuItemSize(BasicMenuItemUI.java:368)
         at javax.swing.plaf.basic.BasicMenuItemUI.getPreferredSize(BasicMenuItemUI.java:305)
         at javax.swing.JComponent.getPreferredSize(JComponent.java:1042)
         at javax.swing.BoxLayout.checkRequests(BoxLayout.java:361)
         at javax.swing.BoxLayout.preferredLayoutSize(BoxLayout.java:194)
         at java.awt.Container.preferredSize(Container.java:833)
         at java.awt.Container.getPreferredSize(Container.java:817)
         at javax.swing.JComponent.getPreferredSize(JComponent.java:1044)
         at javax.swing.JRootPane$RootLayout.layoutContainer(JRootPane.java:694)
         at java.awt.Container.layout(Container.java:686)
         at java.awt.Container.doLayout(Container.java:676)
         at java.awt.Container.validateTree(Container.java:750)
         at java.awt.Container.validateTree(Container.java:757)
         at java.awt.Container.validateTree(Container.java:757)
         at java.awt.Container.validate(Container.java:728)
         at sun.applet.AppletPanel.run(AppletPanel.java:359)
         at java.lang.Thread.run(Thread.java:484)

      This is very similar to bug # 4280648: java.lang.NullPointerException occurred by file saving with appletviewer.

      In the case of 4280648 the exception was java.lang.NullPointerException at plaf.basic.BasicMenuBarUI. uninstallListeners

      I wrote up another bug #4320454 because non-serializable applets should not be allowed to be saved.

      Name: apR10133 Date: 01/10/2002


          Here is the modified testcase which gets more information about
      nature of this NPE:
      ---------------------- Test.java --------------------------
      import javax.swing.*;
      import java.awt.*;
      import java.awt.event.*;
      import java.io.*;

      public class Test implements ActionListener {
          
          JMenu menu;

          public Test() {
      JFrame fr = new JFrame("Test");

      JMenuBar menuBar = new JMenuBar();
      fr.setJMenuBar(menuBar);
      menu = new JMenu("TOOLS");
      menuBar.add(menu);
      menu.add(new JMenuItem("TOOL1"));
      menu.add(new JMenuItem("TOOL2"));
      menu.add(new JMenuItem("TOOL3"));

      JButton fire = new JButton("FIRE");
      fire.addActionListener(this);
      fr.getContentPane().add(fire);

      fr.setSize(200,100);
      fr.setVisible(true);
          }

          public void actionPerformed(ActionEvent e) {
      try {
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      ObjectOutputStream oos = new ObjectOutputStream(baos);
      oos.writeObject(menu);
      System.out.println("Menu serialization succed.");
      } catch (Exception se) {
      se.printStackTrace();
      }
          }
          
          public static void main(String[] argv) {
      new Test();
          }
      }
      --------------------------------------------------------------------

      ======================================================================

      Attachments

        Issue Links

          Activity

            People

              apikalev Andrey Pikalev
              nschorrsunw Nancy Schorr (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: