Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5082816

LTP: MatteBorder can't be serialized to XML.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.0, 5.0
    • client-libs
    • generic, x86
    • generic, windows_xp

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

            malenkov Sergey Malenkov (Inactive)
            jleesunw Jon Lee (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: