JDK-6471539 : LTP: XMLEncoder miss write out javabean property of Point
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.beans
  • Affected Version: 6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2006-09-15
  • Updated: 2011-01-19
  • Resolved: 2006-09-22
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b100Fixed
Related Reports
Relates :  
Relates :  
Description
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.

Comments
EVALUATION This bug was introduced in mustang-b76 after 4741757 was fixed. But it can be reproduced always with installed SecurityManager. We should fix persistence delegates for the following classes: Point, Dimension, Rectange and Insets. We should add the following method to all classes: protected boolean mutatesTo(Object oldInstance, Object newInstance) { return oldInstance.equals( newInstance ); } It is necessary, because Swing uses Point (and other classes) to set and return property value, but this value is not changed when returned value is changed.
18-09-2006