Faster Java Serialization
Copyright (C) 2006 by Leonardo "Bubble" Mesquita
Overview
| Documentation
| Project page
| Downloads
| FAQ
| Benchmarks
Overview
The goal of the project is to enable faster serialization by
generating bytecodes on the fly to serialize objects.
When an object is serialized, its class is inspected and
a class that implements the Serializer interface is generated.
This class is tailor made to serialize the fields of the given
object's class directly.
To serialize objects to a ByteBuffer, all you have to do is add
jserial.jar
to the classpath and
use the SerializationContext
class:
...
SerializationContext context = new SerializationContext();
ByteBuffer buffer = ByteBuffer.allocate(1024);
context.serialize(myObject, buffer);
...
Serializes myObject
. Note that, in order to be
serialized, objects must implement java.io.Serializable
To reconstruct the object, all you have to do is use the
DeserializationContext
class:
...
DeserializationContext context = new DeserializationContext();
MyObject reconstructedObject = (MyObject)context.deserialize(buffer);
...
Reads the reconstructedObject
. In the meantime, the data
in the ByteBuffer can easily be written to a file or sent through a network
using Java NIO.
This project uses a modified version of Javassist-3.3
to perform code-generation on-the-fly.
Limitations
Currently, the project will only serialize objects that:
- Implement
java.io.Serializable
- Have a non private no-args constructor
Features not yet supported include:
- Custom serialization through
java.io.Externalizable
- Custom serialization through
writeObject
, readObject
,
writeReplace
, readResolve
or any other special serialization method.
- Inner/Local/Anonymous class serialization.
- Serialization of non-static final fields, though no error will arise when serializing
objects that have such fields.
We do not support serialization versioning, nor intend to. The focus of the project is to provide
fast serialization, not secure nor "evolving". The user must guarantee that classes
of objects being serialized/deserialized with this library have the same version.
Acknowledgements
I'd like to thank the following people for their support:
- Tiago Luz Pinto, for developing the original concept of "code-generated serialization",
and being a great supporter of this project. (Don't worry, your name will be in the paper,
if I ever get it done ;-D )
- Rodrigo Damazio, for inspiration and motivation. I don't think I'd have gone so far if it weren't for him.
- Daniel Sperry: for "sharing in the excitement of discover without vain attempts to claim priority" ;-)
- All the folks at Hoplon Infotainment, in special Carlos Knippschield,
with whom I spent many long hours generating code and serializing stuff... :-D
- And finally, most of all, Marina Signorini, my beloved girlfriend, who put up with the long hours I have
dedicated to this project in my spare time.
Faster Java Serialization was developed by
Leonardo "Bubble" Mesquita