classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cp-patches] FYI: Add exception cause to swing.text assertion errors


From: Mark Wielaard
Subject: Re: [cp-patches] FYI: Add exception cause to swing.text assertion errors
Date: Sun, 30 Oct 2005 23:03:22 +0100

Hi,

On Sun, 2005-10-30 at 18:59 +0100, Mark Wielaard wrote:
> This shows the following cause for an assertion exception when running
> our Demo:
> 
> Caused by: javax.swing.text.BadLocationException: len plus where cannot be 
> greater than the content length
>    at javax.swing.text.GapContent.getChars (GapContent.java:405)
>    at javax.swing.text.AbstractDocument.getText (AbstractDocument.java:518)
>    at javax.swing.text.PlainView.determineMaxLineLength (PlainView.java:254)
>    ...41 more
> 
> Not yet investigated.

Found it. Small typo. We weren't getting the correct length of the text
we wanted to measure. Fixed as follows with two new AssertionErrors for
cases that "cannot happen".

2005-10-30  Mark Wielaard  <address@hidden>

    * javax/swing/text/PlainView.java (determineMaxLineLength): Get
    correct lenght of text.
    (drawLine): Throw AssertionError on unexpected bad location.
    (viewToModel): Likewise.

Committed,

Mark
Index: javax/swing/text/PlainView.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/PlainView.java,v
retrieving revision 1.28
diff -u -r1.28 PlainView.java
--- javax/swing/text/PlainView.java     30 Oct 2005 18:02:53 -0000      1.28
+++ javax/swing/text/PlainView.java     30 Oct 2005 21:57:10 -0000
@@ -148,7 +148,9 @@
       }
     catch (BadLocationException e)
       {
-       // This should never happen.
+       AssertionError ae = new AssertionError("Unexpected bad location");
+       ae.initCause(e);
+       throw ae;
       }
   }
 
@@ -251,7 +253,7 @@
         int end = child.getEndOffset();
         try
           {
-            el.getDocument().getText(start, start + end, seg);
+            el.getDocument().getText(start, end - start, seg);
           }
         catch (BadLocationException ex)
           {
@@ -332,7 +334,9 @@
     }
     catch (BadLocationException ble)
     {
-      //this should never happen
+      AssertionError ae = new AssertionError("Unexpected bad location");
+      ae.initCause(ble);
+      throw ae;
     }
     
     int pos = Utilities.getTabbedTextOffset(s, metrics, rec.x, (int)x, this, 
start);

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]