JDK-4770950 : A bug of javax.swing.JTextField
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.3.1_08,1.4.0,1.4.1
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,windows_xp
  • CPU: generic,unknown,x86
  • Submitted: 2002-10-30
  • Updated: 2004-09-21
  • Resolved: 2002-11-16
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.
Other Other
1.3.1_14Fixed 1.4.2 mantisFixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Description
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)

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.3.1_14 mantis FIXED IN: 1.3.1_14 mantis INTEGRATED IN: mantis mantis-b08
02-10-2004

EVALUATION Name: ik75403 Date: 11/01/2002 AbstractDocument.MultiByteProperty is an Object. When character > 255 is to be shown in the text component MultiByteProperty is stored in the attributes hashtable. Object is not serializable thus that hashtable not serializable thus text component not serializable. The only thing we need from that property is uniqueness. We might use any serializable object instead of Object. String will do for example ------- AbstractDocument.java ------- 1566c1566 < static final Object MultiByteProperty = new Object(); --- > static final Object MultiByteProperty = new String(); ====================================================================== < static final Object MultiByteProperty = new Object(); --- > static final Object MultiByteProperty = "multiByte"; ###@###.### 2004-09-21
21-09-2004