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)
======================================================================