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

LTP: XMLEncoder doesn't save state for Class properties with default values

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 7
    • 2.0, 1.4.0
    • client-libs
    • b20
    • x86, sparc
    • linux, solaris_8
    • Not verified

      Bean properties of type Class are not persisted by the XMLEncoder if they have been assigned a default value by the bean. To reproduce, use the following bean classes:

      public class Bean1
      {
      public Class getClassProperty()
      {
      return classProperty;
      }

      public void setClassProperty(Class value)
      {
      classProperty=value;
      }

      private String stringProperty;
      private Class classProperty=Object.class; // <-- here is problem
      }

      public class Bean2
      {
      public Class getClassProperty()
      {
      return classProperty;
      }

      public void setClassProperty(Class value)
      {
      classProperty=value;
      }

      private String stringProperty;
      private Class classProperty;
      }

      Before encoding each bean, change the value of the bean's classProperty to e.g. java.lang.Integer. After encoding, the value of this property will not be represented in the XML output for Bean1.

      Bean1:
      {classProperty=class java.lang.Integer}

      <?xml version="1.0" encoding="UTF-8"?>
      <java version="1.4.1" class="java.beans.XMLDecoder">
          <object class="com.sun.jato.tools.sunone._temp.Bean1"/>
      </java>

      Bean2:
      {classProperty=class java.lang.Integer}

      <?xml version="1.0" encoding="UTF-8"?>
      <java version="1.4.1" class="java.beans.XMLDecoder">
          <object class="com.sun.jato.tools.sunone._temp.Bean2">
              <void property="classProperty">
                  <class>java.lang.Integer</class>
              </void>
          </object>
      </java>

      ###@###.### 2003-02-13

            malenkov Sergey Malenkov (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: