JDK-6818231 : JEditorPane throws StateInvariantError
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6u14
  • Priority: P1
  • Status: Closed
  • Resolution: Fixed
  • OS:
    linux,linux_redhat_5.2,solaris_10,windows_xp linux,linux_redhat_5.2,solaris_10,windows_xp
  • CPU: x86,itanium
  • Submitted: 2009-03-17
  • Updated: 2012-10-01
  • Resolved: 2009-05-18
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.
JDK 6 JDK 7
6u14 b04Fixed 7Resolved
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.6.0_14-ea"
Java(TM) SE Runtime Environment (build 1.6.0_14-ea-b03)
Java HotSpot(TM) Server VM (build 14.0-b12, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Linux 2.6.27-13-generic #1 SMP Thu Feb 26 07:26:43 UTC 2009 i686 GNU/Linux

A DESCRIPTION OF THE PROBLEM :
I'm using 1.6.0_14 to test the application. The exception can be reproduced always on my machine using the attached test. Slightly changing the displayed string in the JEditorPane often fixes the problem.
The problem can not be reproduced on 1.6.0_10 or 1.6.0_12.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
see sourcecode

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Frame containing JEditorPane is shown.
ACTUAL -
Exception printed in console.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "AWT-EventQueue-0" javax.swing.text.StateInvariantError: GlyphView: Stale view: javax.swing.text.BadLocationException: Length must be positive
	at javax.swing.text.GlyphView.getText(GlyphView.java:118)
	at javax.swing.text.GlyphView.getBreakSpotUseWhitespace(GlyphView.java:740)
	at javax.swing.text.GlyphView.getBreakSpot(GlyphView.java:732)
	at javax.swing.text.GlyphView.breakView(GlyphView.java:704)
	at javax.swing.text.html.InlineView.breakView(InlineView.java:165)
	at javax.swing.text.FlowView$FlowStrategy.layoutRow(FlowView.java:510)
	at javax.swing.text.FlowView$FlowStrategy.layout(FlowView.java:460)
	at javax.swing.text.FlowView.layout(FlowView.java:184)
	at javax.swing.text.BoxView.setSize(BoxView.java:380)
	at javax.swing.text.BoxView.updateChildSizes(BoxView.java:349)
	at javax.swing.text.BoxView.setSpanOnAxis(BoxView.java:331)
	at javax.swing.text.BoxView.layout(BoxView.java:691)
	at javax.swing.text.BoxView.setSize(BoxView.java:380)
	at javax.swing.text.BoxView.updateChildSizes(BoxView.java:344)
	at javax.swing.text.BoxView.setSpanOnAxis(BoxView.java:317)
	at javax.swing.text.BoxView.layout(BoxView.java:691)
	at javax.swing.text.BoxView.setSize(BoxView.java:380)
	at javax.swing.text.BoxView.updateChildSizes(BoxView.java:349)
	at javax.swing.text.BoxView.setSpanOnAxis(BoxView.java:331)
	at javax.swing.text.BoxView.layout(BoxView.java:691)
	at javax.swing.text.BoxView.setSize(BoxView.java:380)
	at javax.swing.text.BoxView.updateChildSizes(BoxView.java:349)
	at javax.swing.text.BoxView.setSpanOnAxis(BoxView.java:331)
	at javax.swing.text.BoxView.layout(BoxView.java:691)
	at javax.swing.text.BoxView.setSize(BoxView.java:380)
	at javax.swing.text.BoxView.updateChildSizes(BoxView.java:349)
	at javax.swing.text.BoxView.setSpanOnAxis(BoxView.java:331)
	at javax.swing.text.BoxView.layout(BoxView.java:691)
	at javax.swing.text.BoxView.setSize(BoxView.java:380)
	at javax.swing.plaf.basic.BasicTextUI$RootView.setSize(BasicTextUI.java:1702)
	at javax.swing.plaf.basic.BasicTextUI.getPreferredSize(BasicTextUI.java:905)
	at javax.swing.JComponent.getPreferredSize(JComponent.java:1634)
	at javax.swing.JEditorPane.getPreferredSize(JEditorPane.java:1414)
	at javax.swing.ScrollPaneLayout.layoutContainer(ScrollPaneLayout.java:769)
	at java.awt.Container.layout(Container.java:1421)
	at java.awt.Container.doLayout(Container.java:1410)
	at java.awt.Container.validateTree(Container.java:1507)
	at java.awt.Container.validateTree(Container.java:1513)
	at java.awt.Container.validateTree(Container.java:1513)
	at java.awt.Container.validateTree(Container.java:1513)
	at java.awt.Container.validateTree(Container.java:1513)
	at java.awt.Container.validate(Container.java:1480)
	at java.awt.Window.show(Window.java:860)
	at java.awt.Component.show(Component.java:1537)
	at java.awt.Component.setVisible(Component.java:1489)
	at java.awt.Window.setVisible(Window.java:841)
	at ch.gridvision.boogs.client.test.StaleViewError.initAndShowGUI(StaleViewError.java:44)
	at ch.gridvision.boogs.client.test.StaleViewError.access$000(StaleViewError.java:7)
	at ch.gridvision.boogs.client.test.StaleViewError$1.run(StaleViewError.java:17)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.*;


public class StaleViewError
{
    @SuppressWarnings({"ALL"})
    public static void main(String[] args)
    {
        EventQueue.invokeLater(new Runnable()
        {
            @Override
            public void run()
            {
                initAndShowGUI();
            }
        });
    }


    private static void initAndShowGUI()
    {
        JFrame frame = new JFrame();

        JEditorPane jEditorPane = new JEditorPane();
        jEditorPane.setEditable(false);
        jEditorPane.setContentType("text/html");

        String text = "<html><body>" +
                      "<table>" +
                      "<tr><td></td><td>" +
                      "/home/abc/daten/00_projekte/boogs/as.asdasdasda.asdas.asdasd/out/production/ch.gridvision.boogs.server:<br>" +
                      "/home/abc/Daten/00_projekte/Boogs/as.asdasdasda.asdas.asdasd/lib/toplink-essentials-2.1-41-sources.jar:<br>" +
                      "</td></tr>" +
                      "</table></body></html>";

        jEditorPane.setText(text);
        frame.getContentPane().add(new JScrollPane(jEditorPane));

        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setBounds(100, 100, 300, 300);
        frame.setVisible(true);
    }
}
---------- END SOURCE ----------

Release Regression From : 6u12
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.

Comments
EVALUATION As a reault of the fix for 6760148, an off-by-one error occurred for certain cases in the javax.swing.text.Utilities.getTabbedTextOffset() method.
24-03-2009

EVALUATION This bug is not reproducible on my current JDK 6 workspace, so it might a Linux specific assigned to the text team
17-03-2009