JDK-5082816 : LTP: MatteBorder can't be serialized to XML.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.beans
  • Affected Version: 1.4.0,5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic,windows_xp
  • CPU: generic,x86
  • Submitted: 2004-08-04
  • Updated: 2006-03-30
  • Resolved: 2006-03-30
Related Reports
Duplicate :  
Relates :  
Description
Name: jl125535			Date: 08/04/2004


FULL PRODUCT VERSION :
java version "1.5.0-beta3"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta3-b61)
Java HotSpot(TM) Client VM (build 1.5.0-beta3-b61, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
The delegate for serializing Matteborder to XML is faulty.

Solution:
Add getTop(), getBottom(), getLeft(), getRight() to EmptyBorder or rewrite delegate.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run code which is just a little modified from your in-JavaDoc example and works for all other beans.

>javac TestCase.java
>java TestCase

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
An XML- file
ACTUAL -
An error message.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.NoSuchMethodException: javax.swing.border.MatteBorder.getTop()
Continuing ...
java.lang.NoSuchMethodException: javax.swing.border.MatteBorder.getLeft()
Continuing ...
java.lang.NoSuchMethodException: javax.swing.border.MatteBorder.getBottom()
Continuing ...
java.lang.NoSuchMethodException: javax.swing.border.MatteBorder.getRight()
Continuing ...
java.lang.NullPointerException
Continuing ...
java.lang.Exception: discarding statement XMLEncoder0.writeObject(MatteBorder0);
Continuing ...

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.*;
import javax.swing.border.MatteBorder;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.beans.XMLEncoder;

public class TestCase
{
  public static void main(String[] args)
  {
    try {
      XMLEncoder enc = new XMLEncoder(new FileOutputStream("Test.xml"));
      enc.writeObject(new MatteBorder(new Insets(0, 0, 0, 0), Color.BLACK));
      enc.close();
    } catch (FileNotFoundException ex) {
      ex.printStackTrace();
    }
  }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Write own delegate.
(Incident Review ID: 289847) 
======================================================================

Comments
EVALUATION Name: sh120115 Date: 08/04/2004 Test case works when using EmptyBorder, but not MatteBorder. Seems like a bug in persistence. ###@###.### 2004-08-04 ====================================================================== This bug is reproducible back through 1.4. ###@###.### 2004-08-05
04-08-2004