Bug 35236 - javax.swing.tree.VariableHeightLayoutCache triggers NullPointerException
Summary: javax.swing.tree.VariableHeightLayoutCache triggers NullPointerException
Status: UNCONFIRMED
Alias: None
Product: classpath
Classification: Unclassified
Component: swing (show other bugs)
Version: unspecified
: P3 normal
Target Milestone: ---
Assignee: Roman Kennke
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-02-17 19:29 UTC by Andrew John Hughes
Modified: 2008-02-17 19:29 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew John Hughes 2008-02-17 19:29:19 UTC
When running gnu.classpath.examples.swing.TreeDemo and double-clicking on one of the icons, the demo throws of an endless stream of exceptions:

Exception during event dispatch:
java.lang.NullPointerException
   at javax.swing.tree.VariableHeightLayoutCache.getBounds(VariableHeightLayoutCache.java:364)
   at javax.swing.plaf.basic.BasicTreeUI.getPathBounds(BasicTreeUI.java:654)
   at javax.swing.JTree.getPathBounds(JTree.java:2688)
   at javax.swing.plaf.basic.BasicTreeUI$FocusHandler.repaintLeadRow(BasicTreeUI.java:2346)
   at javax.swing.plaf.basic.BasicTreeUI$FocusHandler.focusLost(BasicTreeUI.java:2336)
   at java.awt.Component.processFocusEvent(Component.java:3763)
   at java.awt.Component.processEvent(Component.java:3681)
   at java.awt.Container.processEvent(Container.java:1028)
   at java.awt.Component.dispatchEventImpl(Component.java:5737)
   at java.awt.Container.dispatchEventImpl(Container.java:1952)
   at java.awt.Component.dispatchEvent(Component.java:2850)
   at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1105)
   at java.awt.DefaultKeyboardFocusManager.handleFocusLost(DefaultKeyboardFocusManager.java:313)
   at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:192)
   at java.awt.Component.dispatchEventImpl(Component.java:5725)
   at java.awt.Container.dispatchEventImpl(Container.java:1952)
   at java.awt.Component.dispatchEvent(Component.java:2850)
   at java.awt.DefaultKeyboardFocusManager.handleFocusGained(DefaultKeyboardFocusManager.java:249)
   at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:188)
   at java.awt.Component.dispatchEventImpl(Component.java:5725)
   at java.awt.Container.dispatchEventImpl(Container.java:1952)
   at java.awt.Window.dispatchEventImpl(Window.java:618)
   at java.awt.Component.dispatchEvent(Component.java:2850)
   at java.awt.EventQueue.dispatchEvent(EventQueue.java:624)
   at java.awt.EventDispatchThread.run(EventDispatchThread.java:88)
   at java.lang.VMThread.run(VMThread.java:120)
Exception during event dispatch:
java.lang.NullPointerException
   at javax.swing.tree.VariableHeightLayoutCache.distance(VariableHeightLayoutCache.java:465)
   at javax.swing.tree.VariableHeightLayoutCache.getPathClosestTo(VariableHeightLayoutCache.java:444)
   at javax.swing.plaf.basic.BasicTreeUI.getClosestPathForLocation(BasicTreeUI.java:763)
   at javax.swing.JTree.getClosestPathForLocation(JTree.java:2779)
   at javax.swing.JTree.getClosestRowForLocation(JTree.java:2786)
   at javax.swing.plaf.basic.BasicTreeUI.paint(BasicTreeUI.java:1564)
   at javax.swing.plaf.metal.MetalTreeUI.paint(MetalTreeUI.java:248)
   at javax.swing.plaf.ComponentUI.update(ComponentUI.java:193)
   at javax.swing.JComponent.paintComponent(JComponent.java:2060)
   at javax.swing.JComponent.paint(JComponent.java:1824)
   at javax.swing.JViewport.paintSimple(JViewport.java:798)
   at javax.swing.JViewport.paintBackingStore(JViewport.java:865)
   at javax.swing.JViewport.paint(JViewport.java:495)
   at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:2341)
   at javax.swing.JComponent.paintImmediately2(JComponent.java:2258)
   at javax.swing.JComponent.paintImmediately(JComponent.java:2096)
   at javax.swing.JComponent.paintImmediately(JComponent.java:2122)
   at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:596)
   at javax.swing.RepaintManager$RepaintWorker.run(RepaintManager.java:171)
   at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:200)
   at javax.swing.RepaintManager$RepaintWorkerEvent.dispatch(RepaintManager.java:115)
   at java.awt.EventQueue.dispatchEvent(EventQueue.java:615)
   at java.awt.EventDispatchThread.run(EventDispatchThread.java:88)
   at java.lang.VMThread.run(VMThread.java:120)

The second exception is repeated continuously as it constantly gets triggered by the event handler.  It appears that invalidatePathBounds makes the rectangle in the NodeRecord object null, but then other methods rely on it being non-null and thus cause the exception above.  getBounds in NodeRecord includes the commment '(compute, if required).' but the body of the method just returns the rectangle.  This method is also not called in most places, instead r.bounds is used directly.  Should we not make bounds private and handle null in getBounds()?