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

java.text.BreakIterator fails to be serialized.

    XMLWordPrintable

Details

    • 1.2beta3
    • sparc
    • solaris_2.5
    • Verified

    Description



      Name: avC70361 Date: 12/04/97



        The java.text.BreakIterator instance obtained with BreakIterator.
      getCharacterInstance(), getLineInstance() etc. methods in spite of implementing
      the java.io.Serializable interface fails to be serialized throwing
      NotSerializableException for one of its auxiliary classes such a
      CharacterBreakData.

      Here is the test demonstrating the bug.
      ------------BreakIteratorTest.java------------
      import java.text.BreakIterator;
      import java.io.IOException;
      import java.io.ByteArrayOutputStream;
      import java.io.ObjectOutputStream;

      public class BreakIteratorTest {

        public static void main(String args[]) {

          ObjectOutputStream stream = null;

          try {

            stream = new ObjectOutputStream(
              new ByteArrayOutputStream()
            );

          } catch(IOException e) {
            System.out.println("Unexpected exception : " + e);
            System.exit(1);
          }

          try {

            stream.writeObject(BreakIterator.getCharacterInstance());

          } catch(IOException e) {
            System.out.println("getCharacterInstance : unexpected exception : " + e);
          }

          try {

            stream.writeObject(BreakIterator.getLineInstance());

          } catch(IOException e) {
            System.out.println("getLineInstance : unexpected exception : " + e);
          }

          try {

            stream.writeObject(BreakIterator.getSentenceInstance());

          } catch(IOException e) {
            System.out.println("getSentenceInstance : unexpected exception : " + e);
          }

          try {

            stream.writeObject(BreakIterator.getWordInstance());

          } catch(IOException e) {
            System.out.println("getWordInstance : unexpected exception : " + e);
          }

          System.exit(0);

        }

      }
      ----------------------------
      ------The test output-------
      #>java BreakIteratorTest
      getCharacterInstance : unexpected exception : java.io.NotSerializableException: java.text.CharacterBreakData
      getLineInstance : unexpected exception : java.io.NotSerializableException: java.text.LineBreakData
      getSentenceInstance : unexpected exception : java.io.NotSerializableException: java.text.SentenceBreakData
      getWordInstance : unexpected exception : java.io.NotSerializableException: java.text.WordBreakData
      ----------------------------
      ======================================================================

      Attachments

        Activity

          People

            bcbeck Brian Beck (Inactive)
            ovlasov Oleksandr Vlasov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: