Name: avC70361 Date: 12/18/97
The java.text.DateFormat instances for some locales are incorrectly
serialized/deserialized, although for a number of locales DateFormat
instances
are serialized/deserialized correctly.
Here is the test demonstrating the bug.
------------------DateFormatTest.java------------
import java.text.*;
import java.util.*;
import java.io.*;
public class DateFormatTest {
public static void main(String args[]) {
Locale[] locales = new Locale[] {
Locale.CANADA,
Locale.CANADA_FRENCH,
Locale.CHINA,
Locale.CHINESE,
Locale.ENGLISH,
Locale.FRANCE,
Locale.FRENCH,
Locale.GERMAN,
Locale.GERMANY,
Locale.ITALIAN,
Locale.ITALY,
Locale.JAPAN,
Locale.JAPANESE,
Locale.KOREA,
Locale.KOREAN,
Locale.PRC,
Locale.SIMPLIFIED_CHINESE,
Locale.TAIWAN,
Locale.TRADITIONAL_CHINESE,
Locale.UK,
Locale.US
};
for(int i = 0; i < locales.length; i++) {
Format format = DateFormat.getDateTimeInstance(DateFormat.FULL,
DateFormat.FULL, locales[i]);
try {
byte[] bytes;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(format);
oos.flush();
baos.close();
bytes = baos.toByteArray();
ObjectInputStream ois = new ObjectInputStream(new
ByteArrayInputStream(bytes));
if (!format.equals(ois.readObject())) {
System.out.println("DateFormat instance for locale " +
locales[i] + " is incorrectly serialized/deserialized.");
} else {
System.out.println("DateFormat instance for locale " +
locales[i] + " is OKAY.");
}
} catch(Exception e) {
e.printStackTrace();
}
}
}
}
-----------------------The test output------------
#>java DateFormatTest
DateFormat instance for locale en_CA is OKAY.
DateFormat instance for locale fr_CA is OKAY.
DateFormat instance for locale zh_CN is incorrectly
serialized/deserialized.
DateFormat instance for locale zh is incorrectly
serialized/deserialized.
DateFormat instance for locale en is OKAY.
DateFormat instance for locale fr_FR is OKAY.
DateFormat instance for locale fr is OKAY.
DateFormat instance for locale de is OKAY.
DateFormat instance for locale de_DE is OKAY.
DateFormat instance for locale it is OKAY.
DateFormat instance for locale it_IT is OKAY.
DateFormat instance for locale ja_JP is incorrectly
serialized/deserialized.
DateFormat instance for locale ja is incorrectly
serialized/deserialized.
DateFormat instance for locale ko_KR is incorrectly
serialized/deserialized.
DateFormat instance for locale ko is incorrectly
serialized/deserialized.
DateFormat instance for locale zh_CN is incorrectly
serialized/deserialized.
DateFormat instance for locale zh_CN is incorrectly
serialized/deserialized.
DateFormat instance for locale zh_TW is incorrectly
serialized/deserialized.
DateFormat instance for locale zh_TW is incorrectly
serialized/deserialized.
DateFormat instance for locale en_GB is incorrectly
serialized/deserialized.
DateFormat instance for locale en_US is OKAY.
--------------------------------------------------
======================================================================