JDK-6589532 : XMLEncoder fails to encode TitledBorders
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.beans
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_9
  • CPU: sparc
  • Submitted: 2007-08-06
  • Updated: 2011-05-18
  • Resolved: 2011-05-18
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 JDK 7
6u4Fixed 7 b20Fixed
Description
FULL PRODUCT VERSION :
1.6.0_02

ADDITIONAL OS VERSION INFORMATION :
Solaris 9 (sparc) 09/04

A DESCRIPTION OF THE PROBLEM :
java.beans.XMLEncoder produces errors when encoding TitledBorders with defaulted title color. This breaks in 1.6.0_02 but works fine in 1.5.0_11.

(my apologies for not having more information in other fields but my Solaris box has no access to the internet).


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
javac test.java
java test


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No errors from XMLEncoder.
ACTUAL -
Errors printed to screen by XMLEncoder (or recieved via the exception handler API)

ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.InstantiationException: sun.swing.PrintColorUIResource
Continuing...
java.lang.Exception: XMLEncoder: discarding statement XMLEncoder.writeObject(PrintColorUIResource)



REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.Color;
import java.beans.XMLEncoder;
import java.io.ByteArrayOutputStream;
import javax.swing.UIManager;

public class test
{
   public static void main(String[] args)
   {
      Color c = UIManager.getColor("TtitledBorder.titledColor");
      new XMLEncoder(new ByteArrayOutputStream()).writeObject(c);
   }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
When creating a TitledBorder, always specify the titleColor rather than relying on the default Ocean color.

Release Regression From : 5.0u11
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.

Comments
EVALUATION The PrintColorUIResource class was added. @ConstructorProperties can't be used, because the equals() method is not implemented properly.
09-08-2007