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

swing popup menus are subject to a variety of "impossible" errors.

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      In this case, windows 11, java "16.0.1", but this is not new. AFAIK it has been a problem
      since the beginning of time.

      A DESCRIPTION OF THE PROBLEM :
      JPopupMenu occasionally gets errors at many phases of their life cycle. I believe
      these are all threading errors, caused by asynchronous events in multiple threads.
      Some are synchronous with the "show" function, others are not. Some are in paths
      where it is possible to catch errors, others are not. Here are a sampling of stack traces:

      Thread [AWT-EventQueue-0] (Suspended (exception ArrayIndexOutOfBoundsException))
      MenuSelectionManager.getSelectedPath() line: 150
      BasicMenuUI$Handler.mousePressed(MouseEvent) line: 524
      IconMenu(Component).processMouseEvent(MouseEvent) line: 6614
      IconMenu(JComponent).processMouseEvent(MouseEvent) line: 3342
      IconMenu(JMenu).processMouseEvent(MouseEvent) line: 82
      IconMenu(Component).processEvent(AWTEvent) line: 6382
      IconMenu(Container).processEvent(AWTEvent) line: 2264
      IconMenu(Component).dispatchEventImpl(AWTEvent) line: 4993
      IconMenu(Container).dispatchEventImpl(AWTEvent) line: 2322
      IconMenu(Component).dispatchEvent(AWTEvent) line: 4825
      LightweightDispatcher.retargetMouseEvent(Component, int, MouseEvent) line: 4934
      LightweightDispatcher.processMouseEvent(MouseEvent) line: 4560
      LightweightDispatcher.dispatchEvent(AWTEvent) line: 4504
      XFrame(Container).dispatchEventImpl(AWTEvent) line: 2308
      XFrame(Window).dispatchEventImpl(AWTEvent) line: 2773
      XFrame(Component).dispatchEvent(AWTEvent) line: 4825
      EventQueue.dispatchEventImpl(AWTEvent, Object) line: 772
      EventQueue$4.run() line: 721
      EventQueue$4.run() line: 715
      AccessController.executePrivileged(PrivilegedAction<T>, AccessControlContext, Class<?>) line: 753
      AccessController.doPrivileged(PrivilegedAction<T>, AccessControlContext) line: 391
      ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(PrivilegedAction<T>, AccessControlContext, AccessControlContext) line: 85
      ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(PrivilegedAction<T>, AccessControlContext) line: 95
      EventQueue$5.run() line: 745
      EventQueue$5.run() line: 743
      AccessController.executePrivileged(PrivilegedAction<T>, AccessControlContext, Class<?>) line: 753
      AccessController.doPrivileged(PrivilegedAction<T>, AccessControlContext) line: 391
      ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(PrivilegedAction<T>, AccessControlContext, AccessControlContext) line: 85
      EventQueue.dispatchEvent(AWTEvent) line: 742
      EventDispatchThread.pumpOneEventForFilters(int) line: 203
      EventDispatchThread.pumpEventsForFilter(int, Conditional, EventFilter) line: 124
      EventDispatchThread.pumpEventsForHierarchy(int, Conditional, Component) line: 113
      EventDispatchThread.pumpEvents(int, Conditional) line: 109
      EventDispatchThread.pumpEvents(Conditional) line: 101
      EventDispatchThread.run() line: 90

      Thread [Game ] (Suspended (exception ArrayIndexOutOfBoundsException))
      owns: Vector<E> (id=95)
      Vector<E>.elementAt(int) line: 466
      MenuSelectionManager.setSelectedPath(MenuElement[]) line: 126
      JPopupMenu(JPopupMenu).setVisible(boolean) line: 777
      JPopupMenu(JPopupMenu).show(Component, int, int) line: 957
      JPopupMenu.show(Component, int, int) line: 33
      G.show(Component, MenuInterface, int, int) line: 2036
      XFrame.show(MenuInterface, int, int) line: 293
      RepaintManager.showMenu(MenuInterface, MenuParentInterface, int, int) line: 295
      HiveGameViewer(exCanvas).show(MenuInterface, int, int) line: 2264
      PopupManager$bsSwingMenu.show(MenuParentInterface, int, int) line: 95
      PopupManager.show(int, int) line: 282
      HiveGameViewer(commonCanvas).doRestorePanZoom(int, int) line: 5124
      HiveGameViewer(commonCanvas).handleDeferredEvent(Object, String) line: 5026
      HiveGameViewer.handleDeferredEvent(Object, String) line: 95
      DeferredEventManager.handleDeferredEvent(DeferredEventHandler) line: 87
      HiveGameViewer(exCanvas).ViewerRun(int) line: 1763
      HiveGameViewer(commonCanvas).ViewerRun(int) line: 6687
      Game(commonPanel).runStep(int) line: 334
      Game.runStep(int) line: 3872
      Game.run() line: 3918
      Thread.run() line: 831

      Thread [AWT-EventQueue-0] (Suspended (exception ArrayIndexOutOfBoundsException))
      owns: Vector<E> (id=95)
      Vector<E>.elementAt(int) line: 466
      MenuSelectionManager.setSelectedPath(MenuElement[]) line: 119
      BasicMenuUI.appendPath(MenuElement[], MenuElement) line: 264
      BasicMenuUI$Handler.mousePressed(MouseEvent) line: 530
      IconMenu(Component).processMouseEvent(MouseEvent) line: 6614
      IconMenu(JComponent).processMouseEvent(MouseEvent) line: 3342
      IconMenu(JMenu).processMouseEvent(MouseEvent) line: 82
      IconMenu(Component).processEvent(AWTEvent) line: 6382
      IconMenu(Container).processEvent(AWTEvent) line: 2264
      IconMenu(Component).dispatchEventImpl(AWTEvent) line: 4993
      IconMenu(Container).dispatchEventImpl(AWTEvent) line: 2322
      IconMenu(Component).dispatchEvent(AWTEvent) line: 4825
      LightweightDispatcher.retargetMouseEvent(Component, int, MouseEvent) line: 4934
      LightweightDispatcher.processMouseEvent(MouseEvent) line: 4560
      LightweightDispatcher.dispatchEvent(AWTEvent) line: 4504
      XFrame(Container).dispatchEventImpl(AWTEvent) line: 2308
      XFrame(Window).dispatchEventImpl(AWTEvent) line: 2773
      XFrame(Component).dispatchEvent(AWTEvent) line: 4825
      EventQueue.dispatchEventImpl(AWTEvent, Object) line: 772
      EventQueue$4.run() line: 721
      EventQueue$4.run() line: 715
      AccessController.executePrivileged(PrivilegedAction<T>, AccessControlContext, Class<?>) line: 753
      AccessController.doPrivileged(PrivilegedAction<T>, AccessControlContext) line: 391
      ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(PrivilegedAction<T>, AccessControlContext, AccessControlContext) line: 85
      ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(PrivilegedAction<T>, AccessControlContext) line: 95
      EventQueue$5.run() line: 745
      EventQueue$5.run() line: 743
      AccessController.executePrivileged(PrivilegedAction<T>, AccessControlContext, Class<?>) line: 753
      AccessController.doPrivileged(PrivilegedAction<T>, AccessControlContext) line: 391
      ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(PrivilegedAction<T>, AccessControlContext, AccessControlContext) line: 85
      EventQueue.dispatchEvent(AWTEvent) line: 742
      EventDispatchThread.pumpOneEventForFilters(int) line: 203
      EventDispatchThread.pumpEventsForFilter(int, Conditional, EventFilter) line: 124
      EventDispatchThread.pumpEventsForHierarchy(int, Conditional, Component) line: 113
      EventDispatchThread.pumpEvents(int, Conditional) line: 109
      EventDispatchThread.pumpEvents(Conditional) line: 101
      EventDispatchThread.run() line: 90

      java version "16.0.1" 2021-04-20
      Java(TM) SE Runtime Environment (build 16.0.1+9-24)
      Java HotSpot(TM) 64-Bit Server VM (build 16.0.1+9-24, mixed mode, sharing)

      G:\share\projects\boardspace-html\htdocs\java\v102>java -jar OnlineLobby.jar
      Screen 20.0 x 11.25 = 22.946949688357275
      Udp service server=false
      Switch to https://Boardspace.net/hive/hivegames/
      Show failed for bridge.JPopupMenu[,0,0,0x0,invalid,layout=javax.swing.plaf.basic.DefaultMenuLayout,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.metal.MetalBorders$PopupMenuBorder@7d85a9d6,flags=8,maximumSize=,minimumSize=,preferredSize=,desiredLocationX=696,desiredLocationY=178,label=,lightWeightPopupEnabled=false,margin=,paintBorder=true] java.lang.ArrayIndexOutOfBoundsException: 0 >= 0




      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      any simple swing menu that is created and shown at runtime. just pound on the
      life cycle - show, select. It takes a hundred clicks or so.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Menus ought to be reliable.

      ACTUAL -
      They're not.

      CUSTOMER SUBMITTED WORKAROUND :
      Partial workaround is to catch errors where possible and retry.



      FREQUENCY : occasionally


            pnarayanaswa Praveen Narayanaswamy
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: