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.
Created attachment 11626 [details] The test application This is a trivial test case that succeeds on Sun's implementation and prints exception in ours.
AFAICS, this is fixed in CVS HEAD.