-
Bug
-
Resolution: Fixed
-
P4
-
2.0, 1.4.0
-
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
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
- duplicates
-
JDK-4818600 XMLEncoder doesn't save state for Class properties with default values
- Closed