Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2074132 | 1.3.0 | Neeraj Bajaj | P3 | Closed | Fixed | 1.3 |
Name: eaR10174 Date: 09/01/2003
The method Document.adoptNode() throws NullPointerException in case when an attribute
node is adopted (see test.java below).
The bug appears in jdk1.5.0beta-b17 and affects a new JCK1.5 test:
api/org_w3c/dom/Document/index.html#AdoptNode[AdoptNode007]
------------------------------------test.java-----------------------------
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.w3c.dom.Document;
import org.w3c.dom.Attr;
public class test {
public static void main(String argv[]) {
new test().run();
}
public void run() {
try {
DocumentBuilderFactory docBF = DocumentBuilderFactory.newInstance();
Document doc1 = docBF.newDocumentBuilder().newDocument();
Document doc2 = docBF.newDocumentBuilder().newDocument();
Attr attr1 = doc1.createAttribute("attr1");
Attr attr2 = (Attr)doc2.adoptNode(attr1);
System.out.println("OK");
} catch (Exception e) {
e.printStackTrace();
return;
}
}
}
--------------------------------------------------------------------------
% java -showversion test
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b17)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b17, mixed mode)
java.lang.NullPointerException
at
com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.adoptNode(CoreDocumentImpl.java:16
17)
at test.run(test.java:20)
at test.main(test.java:9)
--------------------------------------------------------------------------
======================================================================
The method Document.adoptNode() throws NullPointerException in case when an attribute
node is adopted (see test.java below).
The bug appears in jdk1.5.0beta-b17 and affects a new JCK1.5 test:
api/org_w3c/dom/Document/index.html#AdoptNode[AdoptNode007]
------------------------------------test.java-----------------------------
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.w3c.dom.Document;
import org.w3c.dom.Attr;
public class test {
public static void main(String argv[]) {
new test().run();
}
public void run() {
try {
DocumentBuilderFactory docBF = DocumentBuilderFactory.newInstance();
Document doc1 = docBF.newDocumentBuilder().newDocument();
Document doc2 = docBF.newDocumentBuilder().newDocument();
Attr attr1 = doc1.createAttribute("attr1");
Attr attr2 = (Attr)doc2.adoptNode(attr1);
System.out.println("OK");
} catch (Exception e) {
e.printStackTrace();
return;
}
}
}
--------------------------------------------------------------------------
% java -showversion test
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b17)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b17, mixed mode)
java.lang.NullPointerException
at
com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.adoptNode(CoreDocumentImpl.java:16
17)
at test.run(test.java:20)
at test.main(test.java:9)
--------------------------------------------------------------------------
======================================================================
- backported by
-
JDK-2074132 Adopting attribute node causes NullPointerException
- Closed