FULL PRODUCT VERSION :
JDK1.6.0-beta2
ADDITIONAL OS VERSION INFORMATION :
windowXP
EXTRA RELEVANT SYSTEM CONFIGURATION :
JDK1.6.0-beta2
A DESCRIPTION OF THE PROBLEM :
XMLEncoder miss write out javabean property of Point on JDK1.6.0-beta2,other JDK version 1.4 and 1.5 is ok.
REGRESSION. Last worked in version mustang
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
import java.awt.Point;
public class MyBean {
// if change code to: Point location = null.
// location information can be write out in xml.
Point location = new Point();
public Point getLocation() {
return location;
}
public void setLocation(Point location) {
this.location = location;
}
}
----------------------------------------------------------
import java.awt.Point;
import java.beans.XMLDecoder;
import java.beans.XMLEncoder;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
public class AAA {
public static void main(String[] args) throws Exception {
MyBean bean = new MyBean();
bean.setLocation(new Point(100, 200));
XMLEncoder e = new XMLEncoder(new BufferedOutputStream(
new FileOutputStream("c:/Test.xml")));
e.writeObject(bean);
e.close();
XMLDecoder d = new XMLDecoder(new BufferedInputStream(
new FileInputStream("c:/Test.xml")));
System.out.println(((MyBean)d.readObject()).getLocation());
d.close();
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
<?xml version="1.0" encoding="UTF-8"?>
<java version="1.6.0-beta2" class="java.beans.XMLDecoder">
<object class="MyBean">
<void property="location">
<object class="java.awt.Point">
<int>100</int>
<int>200</int>
</object>
</void>
</object>
</java>
ACTUAL -
<?xml version="1.0" encoding="UTF-8"?>
<java version="1.6.0-beta2" class="java.beans.XMLDecoder">
<object class="MyBean"/>
</java>
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.Point;
public class MyBean {
// if change code to: Point location = null.
// location information can be write out in xml.
Point location = new Point();
public Point getLocation() {
return location;
}
public void setLocation(Point location) {
this.location = location;
}
}
----------------------------------------------------------
import java.awt.Point;
import java.beans.XMLDecoder;
import java.beans.XMLEncoder;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
public class AAA {
public static void main(String[] args) throws Exception {
MyBean bean = new MyBean();
bean.setLocation(new Point(100, 200));
XMLEncoder e = new XMLEncoder(new BufferedOutputStream(
new FileOutputStream("c:/Test.xml")));
e.writeObject(bean);
e.close();
XMLDecoder d = new XMLDecoder(new BufferedInputStream(
new FileInputStream("d:/Test.xml")));
System.out.println(((MyBean)d.readObject()).getLocation());
d.close();
}
}
------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<java version="1.6.0-beta2" class="java.beans.XMLDecoder">
<object class="MyBean"/>
</java>
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
// if change code to: Point location = null.
// location information can be write out in xml.
Point location = new Point();
Release Regression From : 5.0u8
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.