[Biojava-l] Serializable
Schreiber, Mark
mark.schreiber@agresearch.co.nz
Wed, 7 Nov 2001 09:13:14 +1300
Hi -
I like the idea of serialization tests and I would write some myself but
my thesis is due at the end of this year and I've got a 3 week trip to
the US and UK to squeeze in ;-)
I imagine that a small number of tests could test a large number of
serializations, ie if a SequenceDB is filled with various types of
sequences, some view sequences some standard, DNA, protein, RNA etc
along with a range of features, nested and otherwise. I think that
should cover most of the core classes. Importantly it would need to call
methods that rely on transient variables to make sure they had been
rebuilt properly.
I made a modification to simple distribution to do custom serialization
namley the AlphabetIndexer is transient and a private readObject()
method is added to rebuild the AlphabetIndexer when the class is
deserialized. This seems to work for me, do you think it is safe?
Possibly we should think about making all classes Serializable unless
there is a reason why they should be rebuilt on deserialization. This
approach is recommended in the book Thinking in Java.
Mark Schreiber
Bioinformatics
AgResearch Invermay
PO Box 50034
Mosgiel
New Zealand
PH: +64 3 489 9175
> -----Original Message-----
> From: Thomas Down [mailto:td2@sanger.ac.uk]
> Sent: Wednesday, November 07, 2001 4:46 AM
> To: Schreiber, Mark
> Cc: biojava-l (E-mail)
> Subject: Re: [Biojava-l] Serializable
>
>
> On Mon, Nov 05, 2001 at 03:31:04PM +1300, Schreiber, Mark wrote:
> > Hi -
> >
> > I have noticed that serialization is sporadically and
> poorly supported,
> > some classes that implement the Serializable interface aren't
> > serializable because some of their members are not. Some
> inner classes
> > are serilizable whereas the outer class isn't so
> effectivley the inner
> > class isn't either.
> >
> > I am going to commit a fixs to some of the problems I have noticed
> > however we should have a think about this as cool java
> things like RMI
> > and EJB seem to depend on serialization.
>
> Hi...
>
> I've also been noticing serialization issues recently -- especially
> related to serialization of Distribution objects, which is quite
> important to some work I'm doing at the moment.
>
> Since a lot of the BioJava APIs are, as you say, nominally
> serializable, I think we should be including some serialization
> test-cases in the main test suite. I'll try to make a point
> of writing serialization tests for any code I modify from now
> on -- a few people doing this and we should have perfect
> serialization pretty quick :-).
>
>
> Going back for a moment to the Distribution serialization issue,
> this seems to be very problematic right now, especially for things
> which rely on AlphabetIndexers (we're currently assuming that
> the indexer will be stable across serialization-deserialization
> of an alphabet, but this is actually very, very, dangerous). I'm
> now quite tempted to write custom serializers. Any distribution
> over a FiniteAlphabet should just be serializable as
> symbol-weight tuples. No dependance on indexers, and we ought
> to be able to use the same code for all the different implementations
> (maybe put it in AbstractDistribution). What do you think?
>
> Thomas.
>
=======================================================================
Attention: The information contained in this message and/or attachments
from AgResearch Limited is intended only for the persons or entities
to which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipients is prohibited by AgResearch
Limited. If you have received this message in error, please notify the
sender immediately.
=======================================================================