Skip to content

Bethibande/serialization

Repository files navigation

Java Serialization

This project aims to create a low-latency serialization framework for Java.

Caution

This framework is still very much work-in-progress. Non-experimental usage is not yet recommended.

Example

import java.nio.ByteBuffer;

@Getter
@Setter
@SerializableType
public class MyClass {

    private int someInteger;
    private boolean someBoolean;
    private String someString;

}

public static void main(String[] args) {
    final ByteBuffer buffer = ByteBuffer.allocateDirect(64);
    final Writer writer = new ByteBufferWriter(buffer);
    final Reader reader = new ByteBufferReader(buffer);

    final MyClass myObject = new MyClass();
    myObject.setSomeInteger(123);
    myObject.setSomeBoolean(true);
    myObject.setSomestring("abc");

    final MyClassSerializer serializer = new MyClassSerializer();
    serializer.bind(writer).write(myObject);

    buffer.flip();

    final MyClassDeserializer deserializer = new MyClassDeserializer();
    final MyClass output = deserializer.bind(reader).read(new MyClass());
}

For more examples see here

Type support

  • ✅ Fully supported
  • ❌ Not yet supported
Type Support
Any primitive type
Any boxed primitive type
String / CharSequence
Any enum type
Arrays
Collections
Other serializable types
Maps
Java time types

Please note that not null annotations are supported. Marking nullable fields as not nullable will omit null-checks, doing so can cause null pointer exceptions at runtime in the event that such a field does contain a null value. However, serializing/deserializing not nullable fields is faster.

About

Low-latency Java serialization

Topics

Resources

License

Stars

Watchers

Forks

Languages