-
Bug
-
Resolution: Fixed
-
P1
-
1.2.0
-
None
-
1.2beta1
-
generic, sparc
-
solaris_2.5.1
-
Not verified
It is no longer possible to serialize awt Font objects. This is because
the Font class now has a FontObject field, and some FontObjects such as
sun.java2d.T1FontObject aren't serializable.
If you try and run the test program below you get:
Font write failed: java.io.NotSerializableException: sun.java2d.T1FontObject
java.io.NotSerializableException: sun.java2d.T1FontObject
at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:753)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:232)
at java.io.ObjectOutputStream.outputClassFields(ObjectOutputStream.java:1351)
at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:383)
at java.awt.Font.writeObject(Font.java:584)
at java.lang.reflect.Method.invoke(Native Method)
at java.io.ObjectOutputStream.invokeObjectWriter(ObjectOutputStream.java:1370)
at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:796)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:232)
at Test.main(Test.java:17)
import java.awt.*;
public class Test extends java.awt.Frame {
public static void main(String argv[]) {
Frame frame = new Test();
frame.setBounds(200,200,200,200);
frame.show();
Font font = frame.getFont();
try {
java.io.FileOutputStream fout = new java.io.FileOutputStream("foo.ser");
java.io.ObjectOutput s = new java.io.ObjectOutputStream(fout);
s.writeObject(font);
s.close();
System.exit(0);
} catch (Exception ex) {
System.err.println("Font write failed: " + ex);
ex.printStackTrace();
}
}
}
KGH 9/21/97
- duplicates
-
JDK-4087042 JDK1.2 java.awt.Font cannot be de-serialized in a JDK1.1.4 VM
-
- Closed
-
-
JDK-4069415 sun.java2d.T1FontObject is not serializable which breaks java.awt.Font
-
- Closed
-