Java Clean Architecture Masterclass

Java Clean Architecture MasterclassNov 20-21

Join

one-nio Javadocs

one-nio

one-nio is a library for building high-performance Java servers. It exposes OS capabilities and selected JDK internal APIs to help high-load applications get the most out of the underlying system.

Key Features

Detailed package description

Table of contents

Serialization

one-nio provides a fast and compact serialization mechanism designed for high-throughput services and long-term schema evolution. It supports:

Serialization features and limitations

Additional details: see the Serialization FAQ

Quick start example

A minimal example showing how to serialize and deserialize a simple object with a transient field:

import one.nio.serial.Serializer;
import java.io.Serializable;

public class Example {
    static class User implements Serializable {
        String name;
        int age;
        transient String password; // will not be serialized

        User(String name, int age, String password) {
            this.name = name;
            this.age = age;
            this.password = password;
        }

        public String toString() {
          return "User{" +
                  "name='" + name + '\'' +
                  ", age=" + age +
                  ", password='" + password + '\'' +
                  '}';
        }
    }

    public static void main(String[] args) throws Exception {
        User alice = new User("Alice", 30, "secret");

        // Serialize to compact byte[]
        byte[] data = Serializer.serialize(alice);

        // Deserialize back
        User copy = (User) Serializer.deserialize(data);

        System.out.println(copy);
    }
}

Serializer generation modes

one-nio generates bytecode for serializers at runtime. Since version 2.2.0, it supports two generation modes:

The mode can be configured with the one.nio.serial.gen.mode system property:

More on the wiki

https://github.com/odnoklassniki/one-nio/wiki

Join libs.tech

...and unlock some superpowers

GitHub

We won't share your data with anyone else.