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

Can't dispose InputContext while it's active. revisited.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.2
    • deploy
    • x86
    • windows_xp



      Name: gm110360 Date: 07/31/2003


      FULL PRODUCT VERSION :
      PLUGIN:
      -------
      Java(TM) Plug-in: Version 1.4.1_01
      Anv�nder JRE-version 1.4.1_01 Java HotSpot(TM) Client VM

      APPLETVIEWER:
      -------------
      java version "1.3.1"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
      Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)



      FULL OS VERSION :
      Windows XP 5.1.2600

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      IE 6.0

      A DESCRIPTION OF THE PROBLEM :
      This is basically a request to reopen Bug 4289940 as the reason to
      close it with "not a bug" did not apply to my situation.
      "I think that all manifestations of this exceptions are produced by
      incorrect overriding of Container's removeNotify() method."

      As you can see in the test cases I do not override the removeNotify()
      method but the exception is thrown every time I run the code with
      the plugin.

      I can also get this situation if I use the 1.3.1 appletviewer.
      The exception occurs if I close the window with the close button [x],
      by pressing alt-F4 or using the menu alternative applet->close.
      NOTE! It does not occur if I close the window by using the menu alternative
      applet->exit (The last alternative.)
      (I am aware that the appletviewer might do an incorrect override of
      removeNotify() but the different behaviour might be worth investigating.)



      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1) Compile the applets given and put them on a web server.

      2) Surf to the applet using IE with plugin or the appletviewer.

      3) Click on the applet and press the 'a' key.

      4a) If using the appletviewer, close the window using alt-F4
          or clicking on the close button [x].
      4b) If using IE with plugin, surf to another page,
          e.g. http://java.sun.com

      5) Examine java consol/output

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The output shall show:

      stop
      destroy

      ACTUAL -
      The output shows:

      stop
      destroy
      java.lang.IllegalStateException: Can't dispose InputContext while it's active
      ...

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      PLUGIN:
      -------
      java.lang.IllegalStateException: Can't dispose InputContext while it's active at sun.awt.im.InputContext.dispose(Unknown Source)
      at java.awt.Window$1$DisposeAction.run(Unknown Source)
      at java.awt.Window.dispose(Unknown Source)
      at sun.plugin.viewer.frame.IExplorerEmbeddedFrame.windowClosing(Unknown Source)
      at java.awt.Window.processWindowEvent(Unknown Source)
      at java.awt.Window.processEvent(Unknown Source)
      at java.awt.Component.dispatchEventImpl(Unknown Source)
      at java.awt.Container.dispatchEventImpl(Unknown Source)
      at java.awt.Window.dispatchEventImpl(Unknown Source)
      at java.awt.Component.dispatchEvent(Unknown Source)
      at java.awt.EventQueue.dispatchEvent(Unknown Source)
      at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
      at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
      at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
      at java.awt.EventDispatchThread.run(Unknown Source)

      APPLETVIEWER:
      -------------
      Exception occurred during event dispatching:
      java.lang.IllegalStateException: Can't dispose InputContext while it's active
              at sun.awt.im.InputContext.dispose(InputContext.java:553)
              at java.awt.Window$1$DisposeAction.run(Window.java:470)
              at java.awt.Window.dispose(Window.java:479)
              at sun.applet.AppletViewer.appletClose(AppletViewer.java:747)
              at sun.applet.AppletViewer$1.windowClosing(AppletViewer.java:185)
              at java.awt.Window.processWindowEvent(Window.java:800)
              at java.awt.Window.processEvent(Window.java:776)
              at java.awt.Component.dispatchEventImpl(Component.java:2593)
              at java.awt.Container.dispatchEventImpl(Container.java:1213)
              at java.awt.Window.dispatchEventImpl(Window.java:914)
              at java.awt.Component.dispatchEvent(Component.java:2497)
              at java.awt.EventQueue.dispatchEvent(EventQueue.java:339)
              at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
      read.java:131)
              at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
      ad.java:98)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
              at java.awt.EventDispatchThread.run(EventDispatchThread.java:85)



      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class TestApplet extends java.applet.Applet {
        private int dir;
        public void start() {
          enableEvents(java.awt.AWTEvent.KEY_EVENT_MASK);
        }
        public void stop() {
          disableEvents(java.awt.AWTEvent.KEY_EVENT_MASK);
          System.out.println("stop");
        }
        public void destroy() {
          System.out.println("destroy");
        }
        protected void processEvent(java.awt.AWTEvent e) {
          if(e.getID() == java.awt.event.KeyEvent.KEY_TYPED) {
            ++dir;
            repaint();
          }
          super.processEvent(e);
        }
        public void paint(java.awt.Graphics g) {
          java.awt.Dimension d = getSize();
          int n = d.width * (dir & 3) / 3;
          g.drawLine(n, 0, d.width - n, d.height);
        }
      }
      ------------
      public class TestApplet2 extends java.applet.Applet {
        private int dir;
        private java.awt.event.KeyListener listener;
        public void start() {
          listener = new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent e) {
              ++dir;
              repaint();
            }
          };
          addKeyListener(listener);
        }
        public void stop() {
          removeKeyListener(listener);
          System.out.println("stop");
        }
        public void destroy() {
          System.out.println("destroy");
        }
        public void paint(java.awt.Graphics g) {
          java.awt.Dimension d = getSize();
          int n = d.height * (dir & 3) / 3;
          g.drawLine(0, n, d.width, d.height - n);
        }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Use deprecated method
      public boolean keyDown(Event evt, int key);
      (Incident Review ID: 185850)
      ======================================================================

            Unassigned Unassigned
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: