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

A bug of javax.swing.JTextField

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 1.4.2
    • 1.3.1_08, 1.4.0, 1.4.1
    • client-libs
    • mantis
    • generic, unknown, x86
    • generic, windows_xp

        In using javax.swing.JTextField, it throws java.io.NotSerializableException
        if a given parameter is a String of Japanese characters (non-ascii characters)
        and try to serialize. JTextField implements Serializable, and when the string
        consists of ascii characters, no exception is thrown.

        The following code is the sample code showing this synopsis. Line 6 causes
        the exception when the parameter given to the constructor is a String of
        Japanese characters (though Japanese characters cannot be shown correctly
        in this text field).



             1 import java.io.*;
             2 import javax.swing.*;
             3
             4 public class Test {
             5 public static void main(String[] args)throws Exception {
             6 JTextField ta = new JTextField("Ƚ");
             7 ObjectOutputStream out = new ObjectOutputStream(System.out);
             8 out.writeObject(ta);
             9 out.close();
            10 }
            11 }



        % java Test > tmpfile
        Exception in thread "main" java.io.NotSerializableException: java.lang.Object
                at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)
                at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
                at java.util.Hashtable.writeObject(Hashtable.java:801)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:324)
                at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:795)
                at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1294)
                at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1245)
                at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
                at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1330)
                at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1302)
                at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1245)
                at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
                at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1330)
                at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1302)
                at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1245)
                at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
                at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
                at Test.main(Test.java:8)

              idk Igor Kushnirskiy (Inactive)
              duke J. Duke
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: