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

LTP: XMLDecoder does not handle nested constructor arguments correctly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 1.4.0
    • client-libs
    • x86
    • windows_nt

      Name: gm110360 Date: 05/31/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 :

      Windows NT 4.0

      A DESCRIPTION OF THE PROBLEM :
      The XMLDecoder appears to ignore the argument of
      a constuctor which is itself the argument of a
      constructor.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. javac XMLReader
      2. java XMLReader Test.xml
      3.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      The layout manager of the panel that is loaded
      from the archive is a FlowLayout - it should be
      a SpringLayout. You can see the layout manager
      property as part of what is printed to the console
      as the description of the panel.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      There are no error messages but the resulting graph is not correct.
      The decoder has called the no argument constructor to the JPanel -
      leaving its layout manager as the default - a FlowLayout.

      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      Test.xml
      --------

      <?xml version="1.0" encoding="UTF-8"?>
      <java version="1.4.0" class="java.beans.XMLDecoder">
       <object id="JPanel0" class="javax.swing.JPanel">
        <object class="javax.swing.SpringLayout">
         <void id="SpringLayout$SpringProxy0" method="getConstraint">
          <string>East</string>
          <object idref="JPanel0"/>
         </void>
        </object>
       </object>
      </java>


      XMLReader.java
      --------------

      import java.beans.XMLDecoder;
      import java.io.BufferedInputStream;
      import java.io.FileInputStream;

      public class XMLReader {

          /**
           * Reads the named archive and returns the root object.
           *
           * @param filename A valid archive that was created with the LTP
           * @return the decoded object graph or null if an error occured.
           */
          public static void main(String[] args) throws Exception {
              if (args.length == 0) {
                  System.out.println("Usage: XMLReader <filename>");
                  return;
              }
              XMLDecoder d = new XMLDecoder(
                      new BufferedInputStream(
                              new FileInputStream(args[0])));
              Object root = d.readObject();
              System.out.println(root);
              d.close();
          }

      }

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

      CUSTOMER WORKAROUND :
      Set the layout manager as a property on the
      panel rather than passing it in as a constructor
      argument.
      (Review ID: 145689)
      ======================================================================

            malenkov Sergey Malenkov (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: