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

jre 1.6 (jaxp ) DOM parser not backward compatible

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • 9
    • 6, 6u10
    • xml
    • generic, x86
    • generic, windows_xp

      FULL PRODUCT VERSION :
      java version "1.6.0_10-ea"
      Java(TM) SE Runtime Environment (build 1.6.0_10-ea-b08)
      Java HotSpot(TM) Client VM (build 1.6.0_10-ea-b08, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Windows -XP

      A DESCRIPTION OF THE PROBLEM :
      The java sorce code shown below parses the attached xml wrong when running with jre 1.6. The same source code parses the xml correctly when I switch to jre 1.5.

      The XML is :

      <?xml version="1.0" encoding="UTF-8"?>
      <rs>
      <data
      input3='aa[15..0]'
      input4='bb[1..0]'
      input6='cc[2..0]'
      input8='dd[31..0]'
      output2='ee[1..0]'
      output4='ff[511..0]'
      output6='gg[15..0]'
      output7='hh[1..0]'
         />
      </rs>

      Java source code is attached in the Source code for an executable test case: section

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Just run the code attached in the in the "Source code for an executable test case:" first with jre 1.5 and then with jre 1.6. You will notice the follwoing difference :

      jre 1.5 ( last to output lines are CORRECTLY parsed ):
      Attribute name is =output6 AND Attribute value is =gg[15..0]
      Attribute name is =output7 AND Attribute value is =hh[1..0]

      jre 1.6 ( last to output lines are IN CORRECTLY parsed ):
      Attribute name is =output6 AND Attribute value is =hh[1..0]]
      Attribute name is =output7 AND Attribute value is =hh[1..0]


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Attribute name is =input3 AND Attribute value is =aa[15..0]
      Attribute name is =input4 AND Attribute value is =bb[1..0]
      Attribute name is =input6 AND Attribute value is =cc[2..0]
      Attribute name is =input8 AND Attribute value is =dd[31..0]
      Attribute name is =output2 AND Attribute value is =ee[1..0]
      Attribute name is =output4 AND Attribute value is =ff[511..0]
      Attribute name is =output6 AND Attribute value is =gg[15..0]
      Attribute name is =output7 AND Attribute value is =hh[1..0]


      ACTUAL -
      Attribute name is =input3 AND Attribute value is =aa[15..0]
      Attribute name is =input4 AND Attribute value is =bb[1..0]
      Attribute name is =input6 AND Attribute value is =cc[2..0]
      Attribute name is =input8 AND Attribute value is =dd[31..0]
      Attribute name is =output2 AND Attribute value is =ee[1..0]
      Attribute name is =output4 AND Attribute value is =ff[511..0]
      Attribute name is =output6 AND Attribute value is =hh[1..0]]
      Attribute name is =output7 AND Attribute value is =hh[1..0]

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      No error reported

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------


      public class DomParserBug {
      Document dom;
      public void runExample() {

                                                parseXmlFile("C:\\_rf\\jrebug.xml");
      parseDocument();

      }


      private void parseXmlFile(String filename){
      //get the factory
      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
      //dbf.setValidating(true);
              dbf.setValidating(false);

      try {

      //Using factory get an instance of document builder
      DocumentBuilder db = dbf.newDocumentBuilder();
      db.setErrorHandler(new MyErrorHandler());

      //parse using builder to get DOM representation of the XML file
      dom = db.parse(filename);




      }catch(ParserConfigurationException pce) {
      pce.printStackTrace();
      }
      catch(SAXParseException spe) {
      spe.printStackTrace();
      }
      catch(IOException ioe) {
      ioe.printStackTrace();
      }
      catch(SAXException se) {
      se.printStackTrace();
      }
      }


      private void parseDocument()
          {
              Element docEle = dom.getDocumentElement();

              NodeList nl = docEle.getElementsByTagName("data");
              if(nl != null && nl.getLength() > 0)
              {
                  for(int i = 0 ; i < nl.getLength();i++)
                  {

                      Element el = (Element)nl.item(i);
                      NamedNodeMap attrsssss = el.getAttributes();

                      for (int ii=0; ii<attrsssss.getLength(); ++ii)
                      {
                          Node attr = attrsssss.item(ii);
                          System.out.println("Attribute name is =" +attr.getNodeName() +" AND Attribute value is ="+attr.getNodeValue());
                      
                      }
                  }
              }

      }




      public static void main(String[] args){
      //create an instance
      DomParserBug dpe = new DomParserBug();
      //call run example
      dpe.runExample();
      }




      // This error handler uses a Logger to log error messages
      class MyErrorHandler implements ErrorHandler {
      public void error(SAXParseException e) {
      System.out.println("error : " +e.toString());

      }

      // This method is called in the event of a non-recoverable error
      public void fatalError(SAXParseException e) {
      System.out.println("fatalError : " +e.toString());
      }

      // This method is called in the event of a warning
      public void warning(SAXParseException e) {
      System.out.println("warning : " +e.toString());
      }


      }

      }



      ---------- END SOURCE ----------

      Release Regression From : 5.0
      The above release value was the last known release where this
      bug was not reproducible. Since then there has been a regression.

            joehw Joe Wang
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: