Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4675802

Common DOM API returns null NodeList

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.4.0
    • deploy
    • x86
    • windows_2000



      Name: gm110360 Date: 04/26/2002


      FULL PRODUCT 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)

      FULL OPERATING SYSTEM VERSION :


      ADDITIONAL OPERATING SYSTEMS :
      Service Pack 2


      EXTRA RELEVANT SYSTEM CONFIGURATION :
      IE 6.0

      A DESCRIPTION OF THE PROBLEM :
      When attempting to retrieve child nodes from an
      HTMLDocument, a null NodeList is returned.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Use the following code in an applet:

      DOMService s = DOMService.getService(this);
      s.invokeAndWait(new DOMAction() {
        public Object run(DOMAccessor a) {
          HTMLDocument doc = (HTMLDocument)a.getDocument(self);
          NodeList l = doc.getChildNodes();
          if (l == null)
              System.err.println("l is null");
          return l;
        }
      });


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      "l is null" is viewable in the console.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.lang.NullPointerException
      at org.Aaern.acp.TestApplet$1.run(TestApplet.java:33)
      at sun.plugin.dom.DOMService.invokeAndWait(Unknown Source)
      at org.Aaern.acp.TestApplet.start(TestApplet.java:23)
      at sun.applet.AppletPanel.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)

      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package org.Aaern.acp;

      import javax.swing.JApplet;
      import javax.swing.JTextArea;
      import javax.swing.JScrollPane;

      import org.w3c.dom.html.*;
      import org.w3c.dom.*;
      import com.sun.java.browser.dom.*;

      public class TestApplet extends JApplet {
          JTextArea text;
          TestApplet self = this;

          public void start() {
              text = new JTextArea();
              getContentPane().add(new JScrollPane(text));
              showStatus("Starting...");
              
              try {
                  DOMService s = DOMService.getService(this);

                  s.invokeAndWait(new DOMAction() {
                      public Object run(DOMAccessor a) {
      HTMLDocument doc = (HTMLDocument)
      a.getDocument(self);
                          NodeList l = doc.getChildNodes();
                          if (l == null) {
                              System.err.println("l is null");
                              text.append("l is null");
                          }

                          Node t;
                          for (int i=0,max=l.getLength();i<max;i++)
                              t = l.item(i);

                          return l;
                      }
                  });
              } catch(Exception e) {
                  e.printStackTrace();
              }
          }
      }
      ---------- END SOURCE ----------
      (Review ID: 145897)
      ======================================================================

            zgu Zhengyu Gu
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: