Name: vrR10176 Date: 05/17/2002
JDK1.4.0-b92 method org.w3c.dom.Text.splitText(int offset) does not work correctly.
Definition of the method in p. 1.2 "Fundamental Interfaces" of DOM Level 2 Core
(http://www.w3.org/TR/DOM-Level-2-Core/core.html) says:
" Interface Text
...
Methods
splitText
Breaks this node into two nodes at the specified offset, ...
When the offset is equal to the length of this node, the new node has no data."
But if the offset is set to the length of the node the method splitText() throws
NullPointerException while must return new empty node.
This bug is not reproduced on JAXP1.2.0-b20.
The bug is necessary to exclude the new JCK1.4a test
api/org_w3c/dom/Text/index.html#SplitText[SplitText006]
failing on JDK1.4.0-b92.
To reproduce the issue execute the following test.
------------ SplitTextTest.java --------------------------
import org.w3c.dom.Text;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.w3c.dom.Document;
import org.w3c.dom.DOMException;
public class SplitTextTest {
public static void main(String argv[]) {
try {
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Text text = document.createTextNode ("0123456789");
int text_length = text.getLength();
System.out.println("Text length: " + text_length);
Text text1 = text.splitText(text_length);
} catch (Throwable e) {
e.printStackTrace();
}
}
}
------------ Logs ----------------------------------------
$ java -version
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
$ javac -d . SplitTextTest.java
$ java -Xfuture SplitTextTest
Text length: 10
java.lang.NullPointerException
at org.apache.crimson.tree.TextNode.splitText(TextNode.java:209)
at SplitTextTest.main(SplitTextTest.java:14)
----------------------------------------------------------
======================================================================
JDK1.4.0-b92 method org.w3c.dom.Text.splitText(int offset) does not work correctly.
Definition of the method in p. 1.2 "Fundamental Interfaces" of DOM Level 2 Core
(http://www.w3.org/TR/DOM-Level-2-Core/core.html) says:
" Interface Text
...
Methods
splitText
Breaks this node into two nodes at the specified offset, ...
When the offset is equal to the length of this node, the new node has no data."
But if the offset is set to the length of the node the method splitText() throws
NullPointerException while must return new empty node.
This bug is not reproduced on JAXP1.2.0-b20.
The bug is necessary to exclude the new JCK1.4a test
api/org_w3c/dom/Text/index.html#SplitText[SplitText006]
failing on JDK1.4.0-b92.
To reproduce the issue execute the following test.
------------ SplitTextTest.java --------------------------
import org.w3c.dom.Text;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.w3c.dom.Document;
import org.w3c.dom.DOMException;
public class SplitTextTest {
public static void main(String argv[]) {
try {
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Text text = document.createTextNode ("0123456789");
int text_length = text.getLength();
System.out.println("Text length: " + text_length);
Text text1 = text.splitText(text_length);
} catch (Throwable e) {
e.printStackTrace();
}
}
}
------------ Logs ----------------------------------------
$ java -version
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
$ javac -d . SplitTextTest.java
$ java -Xfuture SplitTextTest
Text length: 10
java.lang.NullPointerException
at org.apache.crimson.tree.TextNode.splitText(TextNode.java:209)
at SplitTextTest.main(SplitTextTest.java:14)
----------------------------------------------------------
======================================================================