-
Bug
-
Resolution: Fixed
-
P3
-
5.0
-
1.3
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2116328 | 5.0 | Venugopal K | P3 | Resolved | Fixed | b55 |
Name: erR10175 Date: 05/17/2004
The following method of the default org.w3c.dom.Document interface implementation
Node importNode(Node importedNode, boolean deep)
throws NullPointerException when a DocumentType node is imported.
The documentation of the method reads:
"
The following list describes the specifics for each type of node.
...
DOCUMENT_TYPE_NODE
DocumentType nodes cannot be imported.
...
Throws:
DOMException - NOT_SUPPORTED_ERR: Raised if the type of node being imported
is not supported.
"
So, in the test (see below) NOT_SUPPORTED_ERR DOMException is expected
instead of NullPointerException.
This bug affects new test in JCK 1.5
api/org_w3c/dom/Document/index.html#ImportNode[ImportNode005]
The bug is found in jdk1.5.0/beta/b51 and is not reproducible in jdk1.5.0/beta/b50.
To reproduce the bug compile and run test.java as shown in the log below:
------------------------------------------ test.java
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.w3c.dom.DocumentType;
import org.w3c.dom.Document;
import org.w3c.dom.DOMException;
class test {
public static void main(String [] args) throws Exception {
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().
newDocumentBuilder();
Document document1 = docBuilder.newDocument();
Document document2 = docBuilder.newDocument();
DocumentType docType = document1.getImplementation()
.createDocumentType("root", null, null);
try {
document2.importNode(docType, false);
System.out.println("Failed: document type node imported,"
+ " no exception is thrown.");
} catch (DOMException e) {
int code = ((DOMException)e).code;
if (DOMException.NOT_SUPPORTED_ERR == code) {
System.out.println("Passed.");
} else {
System.out.println("Failed: Unexpected error code "
+ code);
}
}
}
}
----------------------------------------------------
------------------------------------------------ log
$javac test.java && java -cp . -showversion test
java version "1.5.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b51)
Java HotSpot(TM) Client VM (build 1.5.0-beta2-b51, mixed mode)
Exception in thread "main" java.lang.NullPointerException
at com.sun.org.apache.xerces.internal.dom.NodeImpl.getUserDataRecord(NodeImpl.java:1836)
at com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.importNode(CoreDocumentImpl.java:1477)
at com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.importNode(CoreDocumentImpl.java:1444)
at test.main(test.java:18)
----------------------------------------------------
======================================================================
The following method of the default org.w3c.dom.Document interface implementation
Node importNode(Node importedNode, boolean deep)
throws NullPointerException when a DocumentType node is imported.
The documentation of the method reads:
"
The following list describes the specifics for each type of node.
...
DOCUMENT_TYPE_NODE
DocumentType nodes cannot be imported.
...
Throws:
DOMException - NOT_SUPPORTED_ERR: Raised if the type of node being imported
is not supported.
"
So, in the test (see below) NOT_SUPPORTED_ERR DOMException is expected
instead of NullPointerException.
This bug affects new test in JCK 1.5
api/org_w3c/dom/Document/index.html#ImportNode[ImportNode005]
The bug is found in jdk1.5.0/beta/b51 and is not reproducible in jdk1.5.0/beta/b50.
To reproduce the bug compile and run test.java as shown in the log below:
------------------------------------------ test.java
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.w3c.dom.DocumentType;
import org.w3c.dom.Document;
import org.w3c.dom.DOMException;
class test {
public static void main(String [] args) throws Exception {
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().
newDocumentBuilder();
Document document1 = docBuilder.newDocument();
Document document2 = docBuilder.newDocument();
DocumentType docType = document1.getImplementation()
.createDocumentType("root", null, null);
try {
document2.importNode(docType, false);
System.out.println("Failed: document type node imported,"
+ " no exception is thrown.");
} catch (DOMException e) {
int code = ((DOMException)e).code;
if (DOMException.NOT_SUPPORTED_ERR == code) {
System.out.println("Passed.");
} else {
System.out.println("Failed: Unexpected error code "
+ code);
}
}
}
}
----------------------------------------------------
------------------------------------------------ log
$javac test.java && java -cp . -showversion test
java version "1.5.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b51)
Java HotSpot(TM) Client VM (build 1.5.0-beta2-b51, mixed mode)
Exception in thread "main" java.lang.NullPointerException
at com.sun.org.apache.xerces.internal.dom.NodeImpl.getUserDataRecord(NodeImpl.java:1836)
at com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.importNode(CoreDocumentImpl.java:1477)
at com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.importNode(CoreDocumentImpl.java:1444)
at test.main(test.java:18)
----------------------------------------------------
======================================================================
- backported by
-
JDK-2116328 Document.importNode() throws NullPointerException for DocumentType node
- Resolved
-
JDK-2116329 Document.importNode() throws NullPointerException for DocumentType node
- Closed