Hi Roman,

On Sun, 2005-09-04 at 11:42 +0200, Roman Kennke wrote:
> > > +FAIL: 
> > > gnu.testlet.javax.swing.text.AbstractDocument.AbstractDocumentTest: 
> > > uncaught exception at "testCreateLeafElement" number 1: 
> > > java.lang.NullPointerException
> > 
> > This one can be trivially fixed by the attached patch that allows a null
> > parent for createLeafElement(). But I haven't actually studied if this
> > is the correct behavior.
> > 
> > Roman, could you take a look at this?
> 
> If the testcase confirms that the parent is allowed to be null, then
> this is ok. I can have a deeper look at this tomorrow.

We allowed it in the past and it masks some other tests (since now the
first test in the batch throws a NullPointerException). But I think it
is a bit of a corner case. All other tests also PASS with this. I have
applied it as follows:

2005-09-04  Mark Wielaard  <[EMAIL PROTECTED]>

        * (LeafElement.LeafElement): Set startPos and endPos through
        createPosition() if parent is null.

But feel free to revert that if further studies indicate that this is
not the optimal solution.

Cheers,

Mark
Index: javax/swing/text/AbstractDocument.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/AbstractDocument.java,v
retrieving revision 1.26
diff -u -r1.26 AbstractDocument.java
--- javax/swing/text/AbstractDocument.java	29 Aug 2005 17:02:02 -0000	1.26
+++ javax/swing/text/AbstractDocument.java	2 Sep 2005 11:59:10 -0000
@@ -1864,16 +1864,30 @@
                        int end)
     {
       super(parent, attributes);
-      try
 	{
-	  startPos = parent.getDocument().createPosition(start);
-	  endPos = parent.getDocument().createPosition(end);
-	}
-      catch (BadLocationException ex)
-	{
-	  throw new AssertionError("BadLocationException must not be thrown "
-				   + "here. start=" + start + ", end=" + end
-				   + ", length=" + getLength());
+	  try
+	    {
+	      if (parent != null)
+		{
+		  startPos = parent.getDocument().createPosition(start);
+		  endPos = parent.getDocument().createPosition(end);
+		}
+	      else
+		{
+		  startPos = createPosition(start);
+		  endPos = createPosition(end);
+		}
+	    }
+	  catch (BadLocationException ex)
+	    {
+	      AssertionError as;
+	      as = new AssertionError("BadLocationException thrown "
+				      + "here. start=" + start
+				      + ", end=" + end
+				      + ", length=" + getLength());
+	      as.initCause(ex);
+	      throw as;
+	    }
 	}
     }
 

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

_______________________________________________
Classpath mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath

Reply via email to