JDK-4587627 : JEditorPane: New NPE in b89
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,solaris_7,windows_nt
  • CPU: generic,x86,sparc
  • Submitted: 2001-12-10
  • Updated: 2001-12-19
  • Resolved: 2001-12-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.0 rc1Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Description
I see the following NPE when using JavaHelp with b89.  To replicate,
run:

/home/larryh/doc/quadralay/projects/Jtest/Output/view1.4

and poke around in the TOC.  It usually doesn't take too long for
this to show up.

croak[50] java full version "1.4.0-rc-b89"
java.lang.NullPointerException
	at javax.swing.text.FlowView.layout(FlowView.java:192)
	at javax.swing.text.BoxView.setSize(BoxView.java:379)
	at javax.swing.text.BoxView.updateChildSizes(BoxView.java:348)
	at javax.swing.text.BoxView.setSpanOnAxis(BoxView.java:330)
	at javax.swing.text.BoxView.layout(BoxView.java:682)
	at javax.swing.text.BoxView.setSize(BoxView.java:379)
	at javax.swing.text.BoxView.updateChildSizes(BoxView.java:343)
	at javax.swing.text.BoxView.setSpanOnAxis(BoxView.java:316)
	at javax.swing.text.BoxView.layout(BoxView.java:682)
	at javax.swing.text.BoxView.setSize(BoxView.java:379)
	at javax.swing.text.BoxView.updateChildSizes(BoxView.java:348)
	at javax.swing.text.BoxView.setSpanOnAxis(BoxView.java:330)
	at javax.swing.text.BoxView.layout(BoxView.java:682)
	at javax.swing.text.FlowView.layout(FlowView.java:196)
	at javax.swing.text.BoxView.setSize(BoxView.java:379)
	at javax.swing.text.BoxView.updateChildSizes(BoxView.java:348)
	at javax.swing.text.BoxView.setSpanOnAxis(BoxView.java:330)
	at javax.swing.text.BoxView.layout(BoxView.java:682)
	at javax.swing.text.BoxView.setSize(BoxView.java:379)
	at javax.swing.text.BoxView.updateChildSizes(BoxView.java:348)
	at javax.swing.text.BoxView.setSpanOnAxis(BoxView.java:330)
	at javax.swing.text.BoxView.layout(BoxView.java:682)
	at javax.swing.text.BoxView.setSize(BoxView.java:379)
	at javax.swing.text.BoxView.updateChildSizes(BoxView.java:348)
	at javax.swing.text.BoxView.setSpanOnAxis(BoxView.java:330)
	at javax.swing.text.BoxView.layout(BoxView.java:682)
	at javax.swing.text.BoxView.setSize(BoxView.java:379)
	at javax.swing.plaf.basic.BasicTextUI$RootView.setSize(BasicTextUI.java:1533)
	at javax.swing.plaf.basic.BasicTextUI.getPreferredSize(BasicTextUI.java:730)
	at javax.swing.JComponent.getPreferredSize(JComponent.java:1262)
	at javax.swing.JEditorPane.getPreferredSize(JEditorPane.java:1206)
	at javax.swing.ViewportLayout.layoutContainer(ViewportLayout.java:120)
	at java.awt.Container.layout(Container.java:835)
	at java.awt.Container.doLayout(Container.java:825)
	at java.awt.Container.validateTree(Container.java:903)
	at java.awt.Container.validateTree(Container.java:910)
	at java.awt.Container.validate(Container.java:878)
	at javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:347)
	at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:116)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:443)
	at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:190)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:144)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:130)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:98)

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: generic FIXED IN: merlin-rc1 INTEGRATED IN: merlin-rc1
14-06-2004

EVALUATION For some subviews of flowView parent was set to null that cause the exception. The problem is that view might be referenced from more than one superview as a child It happens in flowView for example. Paragraph | LogicalView V | ParagraphRow | | | V | ComponentView <------ FlowView.FlowStrategy.layout removes all views. It calls setParent(null) for every one of them. After that it reparents all children of logicalView to logicalView. (it calls setParent(logicalView)) (Two views can share the same view as a children but view can have only one parent) Calling View.setParent(null) propagates null parent to all children views. Calling View.setParent(something) does not propogate not null parent to the children. Thus we have incorrect tree structure. Here is how to fix the problem. view.setParent(null) should be called if and only if that view is not needed anymore and it will not be used. There are two cases when view.setParent(null) is called by mistake. 1. directly 2. because parent.setParent(null) was called. We can say that view C is a 'real' child of view P if C.getParent() == P Case one happens in CompositView.java in replace method. It calls setParent(null) for all replaced children. But we need to call it only for the 'real' replaced children. Case two happens in View.setParent method. It propagates null parent to all its children. Instead it should do it only for the 'real' children. The last thing is to change FlowView.FlowStrategy.layout to reparent children of logicalView before removing them. ###@###.### 2001-12-18
18-12-2001