Bug 27930 - DefaultStyledDocument.insert(int, ElementSpec[]) fails with more than one member in array.
Summary: DefaultStyledDocument.insert(int, ElementSpec[]) fails with more than one mem...
Status: RESOLVED FIXED
Alias: None
Product: classpath
Classification: Unclassified
Component: swing (show other bugs)
Version: 0.92
: P3 normal
Target Milestone: 0.93
Assignee: Roman Kennke
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-06-07 13:10 UTC by Audrius Meškauskas
Modified: 2006-10-10 20:19 UTC (History)
1 user (show)

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


Attachments
The test application (1.93 KB, text/plain)
2006-06-07 13:11 UTC, Audrius Meškauskas
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Audrius Meškauskas 2006-06-07 13:10:09 UTC
DefaultStyledDocument.insert(int, ElementSpec[]) fails with more than one member in array with the following exception:

Exception during event dispatch:
java.lang.AssertionError: BadLocationException should not be thrown here. p0 = 31, p1 = 41
   at javax.swing.text.GlyphView.getText(GlyphView.java:728)
   at javax.swing.text.GlyphView$DefaultGlyphPainter.getSpan(GlyphView.java:387)   at javax.swing.text.GlyphView.getPreferredSpan(GlyphView.java:565)
   at javax.swing.text.View.getMinimumSpan(View.java:183)
   at javax.swing.text.BoxView.updateChildRequirements(BoxView.java:949)
   at javax.swing.text.BoxView.calculateMinorAxisRequirements(BoxView.java:483)
   at javax.swing.text.BoxView.updateRequirements(BoxView.java:973)
   at javax.swing.text.BoxView.getMinimumSpan(BoxView.java:343)
   at javax.swing.text.FlowView.calculateMinorAxisRequirements(FlowView.java:600)
   at javax.swing.text.BoxView.updateRequirements(BoxView.java:973)
   at javax.swing.text.BoxView.getMinimumSpan(BoxView.java:343)
   at javax.swing.text.BoxView.updateChildRequirements(BoxView.java:949)
   at javax.swing.text.BoxView.calculateMinorAxisRequirements(BoxView.java:483)
   at javax.swing.text.BoxView.updateRequirements(BoxView.java:973)
   at javax.swing.text.BoxView.getPreferredSpan(BoxView.java:307)
   at javax.swing.plaf.basic.BasicTextUI$RootView.getPreferredSpan(BasicTextUI.java:240)
   at javax.swing.plaf.basic.BasicTextUI.getPreferredSize(BasicTextUI.java:880)
   at javax.swing.JComponent.getPreferredSize(JComponent.java:1333)
   at javax.swing.JEditorPane.getPreferredSize(JEditorPane.java:697)
   at javax.swing.ScrollPaneLayout.layoutContainer(ScrollPaneLayout.java:337)
   at java.awt.Container.layout(Container.java:539)
   at java.awt.Container.doLayout(Container.java:528)
   at java.awt.Container.validateTree(Container.java:615)
   at java.awt.Container.validateTree(Container.java:624)
   at java.awt.Container.validateTree(Container.java:624)
   at java.awt.Container.validateTree(Container.java:624)
   at java.awt.Container.validateTree(Container.java:624)
   at java.awt.Container.validateTree(Container.java:624)
   at java.awt.Container.validateTree(Container.java:624)
   at java.awt.Container.validate(Container.java:565)
   at java.awt.Window.show(Window.java:325)
   at java.awt.Component.show(Component.java:934)
   at java.awt.Component.setVisible(Component.java:884)
   at gnu.classpath.examples.swing.TextDemo$1.run(TextDemo.java:166)
   at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:200)
   at java.awt.EventQueue.dispatchEvent(EventQueue.java:465)
   at java.awt.EventDispatchThread.run(EventDispatchThread.java:95)
Caused by: javax.swing.text.BadLocationException: the where argument cannot be greater than the content length
   at javax.swing.text.GapContent.getChars(GapContent.java:415)
   at javax.swing.text.AbstractDocument.getText(AbstractDocument.java:537)
   at javax.swing.text.GlyphView.getText(GlyphView.java:723)
   ...36 more

The call succeeds and the content is inserted if the passed array contains only one element. In this case, multiple subsequent calls also succeed, so it would be possible to write a trivial workaround. This, however, may not be effective.

This method is protected, but it call be called from the overridden classes and may be later used in HTMLDocument.
Comment 1 Audrius Meškauskas 2006-06-07 13:11:35 UTC
Created attachment 11626 [details]
The test application

This is a trivial test case that succeeds on Sun's implementation and prints exception in ours.
Comment 2 Roman Kennke 2006-10-10 20:19:21 UTC
AFAICS, this is fixed in CVS HEAD.