JDK-6771315 : Error in implementation of Document.createDocumentFragment, createTextNode and createComment
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 6u12
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2008-11-13
  • Updated: 2010-09-08
  • Resolved: 2009-01-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
6u12 b02Fixed
###@###.### discovered that adding a newly-created text node to a part of the HTML document was causing errors. The root cause is a cut-and-paste typo in a few methods of the Document class causing the wrong JavaScript object to be wrapped and returned to the caller, and later inserted into the DOM hierarchy.

The test case is as follows:
import java.lang.reflect.*;
import org.w3c.dom.*;
import org.w3c.dom.html.*;

public class DOMAdd extends java.applet.Applet
    public void start()
            Class c = Class.forName("com.sun.java.browser.plugin2.DOM");
            Method m = c.getMethod("getDocument",
                                   new Class[] { java.applet.Applet.class });
            HTMLDocument doc = (HTMLDocument) m.invoke(null, new Object[] { this });
            Element e = doc.createElement("div");
            Text t = doc.createTextNode("Test passed.");
            System.out.println("Test passed.");
        catch (Exception e)
            System.out.println("TEST FAILED");

      DOM Add test applet
    <applet code=DOMAdd.class
      width=10 height=10

SUGGESTED FIX webrev: http://sa.sfbay.sun.com/projects/deployment_data/6u12/6771315.0 testcase: http://j2se.east.sun.com/deployment/www/tests/1.6.0_12/6771315/

EVALUATION A cut-and-paste typo in a few key methods of the Document class cause wrapping of the wrong object (the containing document rather than the newly-created node) which prevents the affected APIs from functioning.