classpath-patches
[Top][All Lists]
Advanced

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

Re: [cp-patches] Patch: Fix ClassCastException caused by javax.swing.tex


From: Mark Wielaard
Subject: Re: [cp-patches] Patch: Fix ClassCastException caused by javax.swing.text.GapContent
Date: Mon, 01 Aug 2005 01:06:10 +0200

Hi Wolfgang,

On Sat, 2005-07-30 at 13:44 +0200, Wolfgang Baer wrote:
> the recent patch from Roman which uses the inner class
> GapContentPosition for the positions in javax.swing.text.GapContent
> breaks the swing demo.
> 
> The attached patch fixes that by using the new GapContentPosition
> class for comparing in Collections.binarySearch instead of the former
> Integer object.

Thanks! I was just looking for what broke.
I committed this as obvious:

2005-08-01  Mark Wielaard  <address@hidden>

        Reported by Wolfgang Baer <address@hidden>
        * javax/swing/text/GapContent.java (shiftGap): Use new
        CapContentPosition in binarySearch.
        (shiftEnd): Likewise.

The CapContentPosition does contain a compareTo() that can handle
Integers, but Integers can of course not be compared to CapContents.

Roman, is there (another) reason why that compareTo() wants to handle
Integers?

Cheers,

Mark
Index: javax/swing/text/GapContent.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/GapContent.java,v
retrieving revision 1.15
diff -u -r1.15 GapContent.java
--- javax/swing/text/GapContent.java    29 Jul 2005 14:57:15 -0000      1.15
+++ javax/swing/text/GapContent.java    31 Jul 2005 23:03:41 -0000
@@ -398,7 +398,8 @@
     buffer = newBuf;
 
     // Update the marks after the gapEnd.
-    int index = Collections.binarySearch(positions, new Integer(gapEnd));
+    int index = Collections.binarySearch(positions,
+                                        new GapContentPosition(gapEnd));
     if (index < 0)
       {
        index = -(index + 1);
@@ -422,8 +423,10 @@
 
     // Update the positions between newGapEnd and (old) gapEnd. The marks
     // must be shifted by (gapEnd - newGapEnd).
-    int index1 = Collections.binarySearch(positions, new Integer(gapEnd));
-    int index2 = Collections.binarySearch(positions, new Integer(newGapEnd));
+    int index1 = Collections.binarySearch(positions,
+                                         new GapContentPosition(gapEnd));
+    int index2 = Collections.binarySearch(positions,
+                                         new GapContentPosition(newGapEnd));
     int i1 = Math.min(index1, index2);
     int i2 = Math.max(index1, index2);
     for (ListIterator i = positions.listIterator(i1); i.hasNext();)

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


reply via email to

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