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

Null Pointer Exception in JTree's getAccessibleContext method

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.3.0
    • client-libs
    • beta
    • generic
    • generic



      Name: krC82822 Date: 02/14/2001


      java version "1.3.0_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0_01)
      Java HotSpot(TM) Client VM (build 1.3.0_01, mixed mode)

      When our application starts up, its display contains an empty JTree, that is a
      tree with no nodes. Its TreeModel is null. This is perfectly valid, and causes
      no problems in normal use.
      We are using a test tool that relies on the accessibility features to discover
      the GUI component hierarchy, in the same way as the Monkey program from the
      Accessibility toolkit. When we invoke Monkey's "refresh trees" function and an
      empty tree is showing, it fails with a NullPointerException, like this:

      java.lang.NullPointerException:
      at javax.swing.JTree$AccessibleJTree.<init>(JTree.java:3247)
      at javax.swing.JTree.getAccessibleContext(JTree.java:3221)
      at ComponentNode.<init>(ComponentNode.java:53)
      at Monkey.addComponentNodes(Monkey.java:153)
      at Monkey.addComponentNodes(Monkey.java:158)
      at Monkey.addComponentNodes(Monkey.java:158)
      at Monkey.addComponentNodes(Monkey.java:158)
      at Monkey.addComponentNodes(Monkey.java:158)
      at Monkey.addComponentNodes(Monkey.java:158)
      at Monkey.addComponentNodes(Monkey.java:158)
      at Monkey.addComponentNodes(Monkey.java:158)
      at Monkey.addComponentNodes(Monkey.java:158)
      at Monkey.addComponentNodes(Monkey.java:158)
      at Monkey.addComponentNodes(Monkey.java:158)
      at Monkey.createComponentTree(Monkey.java:197)
      at Monkey.refreshTrees(Monkey.java:94)
      at Monkey$1.actionPerformed(Monkey.java:118)
      at javax.swing.AbstractButton.fireActionPerformed
      (AbstractButton.java:1450)
      at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed
      (AbstractButton.java:1504)
      at javax.swing.DefaultButtonModel.fireActionPerformed
      (DefaultButtonModel.java:378)
      at javax.swing.DefaultButtonModel.setPressed
      (DefaultButtonModel.java:250)
      at javax.swing.AbstractButton.doClick(AbstractButton.java:279)
      at
      javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseReleased
      (BasicMenuItemUI.java:886)
      at java.awt.Component.processMouseEvent(Component.java:3717)
      at java.awt.Component.processEvent(Component.java:3546)
      at java.awt.Container.processEvent(Container.java:1164)
      at java.awt.Component.dispatchEventImpl(Component.java:2595)
      at java.awt.Container.dispatchEventImpl(Container.java:1213)
      at java.awt.Component.dispatchEvent(Component.java:2499)
      at java.awt.LightweightDispatcher.retargetMouseEvent
      (Container.java:2451)
      at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2216)
      at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2125)
      at java.awt.Container.dispatchEventImpl(Container.java:1200)
      at java.awt.Window.dispatchEventImpl(Window.java:912)
      at java.awt.Component.dispatchEvent(Component.java:2499)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:319)
      at java.awt.EventDispatchThread.pumpOneEvent
      (EventDispatchThread.java:103)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:84)

      The constructor for AccessibleJTree does not cater for the tree model to be
      null, although other parts of JTree (notably setModel()) make explicit checks
      for this. Line 3247 in JTree.java, in the constructor for AccessibleJTree,
      needs to be changed from this:

                  JTree.this.getModel().addTreeModelListener(this);

      to this:

                  TreeModel treeModel = JTree.this.getModel();
                  if (treeModel != null)
                      treeModel.addTreeModelListener(this);
      (Review ID: 116937)
      ======================================================================

            lmonsantsunw Lynn Monsanto (Inactive)
            kryansunw Kevin Ryan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: