-
Bug
-
Resolution: Fixed
-
P2
-
1.3.1_08, 1.4.0, 1.4.1
-
mantis
-
generic, unknown, x86
-
generic, windows_xp
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2120671 | 1.3.1_14 | Sathianantha Thilagar | P2 | Resolved | Fixed | b01 |
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)
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)
- backported by
-
JDK-2120671 A bug of javax.swing.JTextField
- Resolved
- duplicates
-
JDK-4771604 Cant be serialized JTextField that contain Japanese character.
- Closed
-
JDK-4513615 AbstractDocument containing multibyte content cannot be serialized
- Closed
- relates to
-
JDK-6356720 REGRESSION: CTE_REGTEST/Generic/4449624 is failing on windows
- Closed