Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4389772
Votes 1
Synopsis SimpleTimeZone not serializable by IIOPInputStream
Category idl:serialization
Reported Against 1.2 , 1.2.1
Release Fixed
State 11-Closed, duplicate of 4365188, bug
Priority: 3-Medium
Related Bugs 4365188
Submit Date 16-NOV-2000
Description




Classic VM (build JDK-1.2.2_006, native threads, nojit)

I defined a CMP entity bean (of type 'TrainingBean') with an attribute (of
type 'Schedule') that collects two GregorianCalendar instances.

import java.util.*;

public class Timespan implements java.io.Serializable
{
    private Calendar m_cFrom;
    private Calendar m_cTo;
    
    public Timespan(Calendar cFrom, Calendar cTo)
    {
        m_cFrom = (Calendar)cFrom.clone();
        m_cTo   = (Calendar)cTo.clone();
    }

    public Timespan()
    {
        m_cFrom = Calendar.getInstance();
        m_cTo   = Calendar.getInstance();
    }

    public Calendar getFrom()
    {
        return m_cFrom;
    }
    
    public Calendar getTo()
    {
        return m_cTo;
    }
}

When I try to create an instance of the EJB 'TrainingBean' an IOException is
thrown in the IIOPInputStream's readFully() method ("Method readFully not
supported"). So this one is left unimplemented...

...but too bad, the readObject() method of class SimpleTimeZone (an attribute
of the Calendar class) calls readFully().

So there either a bug in the IIOPInputStream's readFully method or in
SimpleTimeZone's readObject.
(Review ID: 108066) 
======================================================================
Work Around




My workaround is rather an escape than a workaround but could help people in
the same trouble: I use the old fashioned millisecond long as attribute for
serialization and to overwrite Timespan's readObject method to create the
corresponding transient Calendar instances. At least it looks like a bean with
Calendar properties. Cruel but at least it works ...and looks like code from
the 80's.

import java.util.*;

public class Timespan implements java.io.Serializable
{
    private long m_lFrom;
    private long m_lTo;
    
    private transient Calendar m_cFrom;
    private transient Calendar m_cTo;
    
    public Timespan(Calendar cFrom, Calendar cTo)
    {
        m_cFrom = (Calendar)cFrom.clone();
        m_cTo   = (Calendar)cTo.clone();
        m_lFrom = m_cFrom.getTime().getTime();
        m_lTo   = m_cTo.getTime().getTime();
    }

    public Timespan()
    {
        m_cFrom = Calendar.getInstance();
        m_cTo   = Calendar.getInstance();
        m_lFrom = m_cFrom.getTime().getTime();
        m_lTo   = m_cTo.getTime().getTime();
    }

    public Calendar getFrom()
    {
        return m_cFrom;
    }
    
    public Calendar getTo()
    {
        return m_cTo;
    }

    private void readObject(java.io.ObjectInputStream ois) throws
ClassNotFoundException, java.io.IOException
    {
        ois.defaultReadObject();
        m_cFrom = Calendar.getInstance();
        m_cFrom.setTime(new Date(m_lFrom));
        m_cTo = (Calendar)m_cFrom.clone();
        m_cTo.setTime(new Date(m_lTo));
    }

}
======================================================================
Evaluation
This has been fixed and integrated in Ladybird and Merlin, already.

It's important that the RI start using Ladybird, especially since it is using the pure ORB rip-int build which picks up important classes like IIOPInputStream from the JDK.

  xxxxx@xxxxx   2000-12-06
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang