2006/3/7, George Harley <[EMAIL PROTECTED]>:
> I wonder what lessons other class library development teams have learned
> in this area ?

BTW, the problem with serialization of crypto keys (various implementations of
java.security.Key) was resolved in 1.5 by introducing a new class
java.security.KeyRep

I'd say
>> 1. just let it be

Thanks,
Mikhail

>
> Best regards,
> George
>
>
> >
> > Paulex Yang (JIRA) wrote:
> >> java.util.TimeZone's default implementation may cause many classes'
> >> serialization non-compatible with RI
> >> --------------------------------------------------------------------------------------------------------
> >>
> >>
> >>          Key: HARMONY-184
> >>          URL: http://issues.apache.org/jira/browse/HARMONY-184
> >>      Project: Harmony
> >>         Type: Bug
> >>   Components: Classlib      Reporter: Paulex Yang
> >>     Priority: Critical
> >>
> >>
> >> Static factory methods, java.util.TimeZone.getInstance(String) and
> >> getDefault(), are only ways to get a TimeZone instance, but Harmony
> >> and RI uses different classes as default implementation, which cause
> >> serialization non-compatible. Further, all classes whose
> >> serialization form includes TimeZone won't compatible with RI, too,
> >> for example, java.util.Calendar(with subclass),
> >> java.text.DateFormat(with subclass), etc.
> >>
> >> But the incompatiblity is hard to be imputed to Harmony, because
> >> Harmony use API class SimpleTimeZone as default implementation, but
> >> RI use a non-API class,  whose full name is sun.util.calendar.ZoneInfo.
> >>
> >> The reproduce procedure:
> >> 1. To serialize TimeZone object to a file in RI, run codes below in RI
> >> public void writeObject(){
> >>         TimeZone zone = TimeZone.getTimeZone("GMT");
> >>         ObjectOutputStream ooutput = null;
> >>         try {
> >>             ooutput = new ObjectOutputStream(new
> >> FileOutputStream("TimeZone.ser"));
> >>             ooutput.writeObject(zone);
> >>         } finally {
> >>             try {
> >>                 if (null != ooutput) {
> >>                     ooutput.close();
> >>                 }
> >>             } catch (Exception e) {
> >>             }
> >>         }
> >> }
> >>
> >> 2. Trying to deserialize this object from file, run codes below
> >> public void readObject(){
> >>         ObjectInputStream oinput = null;
> >>         try {
> >>             oinput = new ObjectInputStream(new
> >> FileInputStream("TimeZone.ser"));
> >>             TimeZone newObj = (TimeZone)oinput.readObject();
> >>         } finally {
> >>             try {
> >>                 if (null != oinput) {
> >>                     oinput.close();
> >>                 }
> >>             } catch (Exception e) {
> >>             }
> >>         }
> >> }
> >>
> >> Run in RI, passes without any failure
> >> Run in Harmony, exception throwed as below:
> >> java.lang.ClassNotFoundException: sun.util.calendar.ZoneInfo
> >>     at java.lang.Class.forName(Class.java:154)
> >>     at
> >> java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:2226)
> >> ... ...
> >>
> >>
> >
> >
>
>

Reply via email to