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

Regression: Disposing Undeocrated JFrame throws NPE

XMLWordPrintable

      Disposing Undecorated JFrame throws NullPointerException. This is regression from the hopper build 07. The bug is reproducible in hopper build 08 and 09 and not on b07 (only solaris 8 and 9 not on win32). Following is the stack trace:

      java.lang.NullPointerException: NullPointerException
              at sun.awt.motif.X11InputMethod.createXICNative(Native Method)
              at sun.awt.motif.X11InputMethod.activate(X11InputMethod.java:265)
              at sun.awt.im.InputContext.activateInputMethod(InputContext.java:342)
              at sun.awt.im.InputContext.focusGained(InputContext.java:306)
              at sun.awt.im.InputContext.dispatchEvent(InputContext.java:218)
              at sun.awt.im.InputMethodContext.dispatchEvent(InputMethodContext.java:180)
              at java.awt.Component.dispatchEventImpl(Component.java:3548)
              at java.awt.Container.dispatchEventImpl(Container.java:1582)
              at java.awt.Window.dispatchEventImpl(Window.java:1585)
              at java.awt.Component.dispatchEvent(Component.java:3439)
              at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1688)
              at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:703)
              at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:406)
              at java.awt.Component.dispatchEventImpl(Component.java:3468)
              at java.awt.Container.dispatchEventImpl(Container.java:1582)
              at java.awt.Window.dispatchEventImpl(Window.java:1585)
              at java.awt.Component.dispatchEvent(Component.java:3439)
              at java.awt.EventQueue.dispatchEvent(EventQueue.java:448)
              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)


      Java Version:
      java version "1.4.1-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b09)
      Java HotSpot(TM) Client VM (build 1.4.1-beta-b09, mixed mode)


      Steps to reproduce:
      1. Compile the program dispose1.java
      2. Run using appletviewer dispose1.java
      3. Throws NPE.
      4. If not, close appet and run again.

      The bug is not reproducible in the following condition:
      1. If you comment frame.dispose() line in the program.
      2. If only Undecorated JFrame is disposed.
      3. If the frame is not undecorated.

      --------------------------------------------------------------------------------

      import java.awt.*;
      import java.applet.*;
      import javax.swing.*;

      /*<applet CODE="disposeTest1" WIDTH=300 HEIGHT=300> </applet>*/

      public class disposeTest1 extends Applet {

              JFrame frame, frame1;


         public void init() {

      frame=new JFrame();
              frame.setTitle("Frame");
      frame.setUndecorated(true);

              frame1=new JFrame();
              frame1.setTitle("Frame1");

              frame.setBackground(Color.red);
              frame.setSize(300,200);
              frame.setLocation(0,0);
              frame.setVisible(true);

              frame1.setBackground(Color.blue);
              frame1.setSize(300,200);
              frame1.setLocation(400,0);
              frame1.setVisible(true);

      }

      public void start() {


      frame.toFront();

      try{
      Thread.sleep(1000);
      }catch(Exception e){
      e.printStackTrace();
      }

      System.out.println("\n****** Disposing the frames ********\n");

      frame.dispose(); //if this line is commented, It does not throw NPE
      frame1.dispose();

      try{
      Thread.sleep(2000);
      }catch(Exception e){
      e.printStackTrace();
      }

      System.out.println("\n****** Frames are disposed ********\n");

      }

      }
      --------------------------------------------------------------------------------

            naoto Naoto Sato
            asamjisunw Aruna Samji (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: