oldratlee / java-modern-tech-practice

😎 Java™ modern tech practice sandbox ⏳

Home Page:https://github.com/oldratlee/java-modern-tech-practice/issues

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

study: serialization

oldratlee opened this issue · comments

🍺 serialization framework

Kryo

  • repo: https://github.com/EsotericSoftware/kryo
  • EsotericSoftware/kryo: Java binary serialization and cloning: fast, efficient, automatic.
  • Kryo is a fast and efficient binary object graph serialization framework for Java.
  • Additional serializers(for some jdk types and some external libs like e.g. joda time) are available in a separate project on github, kryo-serializers.

JBoss Marshalling

  • repo: https://github.com/jboss-remoting/jboss-marshalling
  • an alternative serialization API that
    • fixes many of the problems found in the JDK serialization API while remaining fully compatible with java.io.Serializable and its relatives,
    • and adds several new tunable parameters and additional features, all of which are pluggable via factory configuration (externalizers, class/instance lookup tables, class resolution, and object replacement, to name a few).
  • this framework was inspired by the need for certain features unavailable with the standard Object*Stream classes
    • Pluggable class resolvers, making it easy to customize classloader policy, by implementing a small interface (rather than having to subclass the Object*Stream classes)
    • Pluggable object replacement (also without subclassing)
    • Pluggable predefined class tables, which can dramatically decrease stream size and serialization time for stream types which frequently use a common set of classes
    • Pluggable predefined instance tables, which make it easy to handle remote references
    • Pluggable externalizers which may be used to serialize classes which are not Serializable, or for which an alternate strategy is needed
    • Customizable stream headers
    • Each marshaller instance is highly configurable and tunable to maximize performance based on expected usage patterns
    • A generalized API which can support many different protocol implementations, including protocols which do not necessarily provide all the above features
    • Inexpensive instance creation, beneficial to applications where many short-lived streams are used
    • Support for separate class and instance caches, if the protocol permits; useful for sending multiple messages or requests with a single stream, with separate object graphs but retaining the class cache
  • home page: http://jbossmarshalling.jboss.org/
  • maintenance is not active...
    • although personally I like the product of jboss and it's high quality 😩

🍺 serialization specification

Protocol Buffers

protostuff

improvement/enhancement of java; independent implementation of java.

Kryo

分析

注意的问题

  • 字段 + 循环引用下有的一个问题:
    CompatibleFieldSerializer fails with IndexOutOfBoundsException on field removal
    EsotericSoftware/kryo#286 (comment)
  • 使用kryo做序列化会遇到的几个坑 https://blog.csdn.net/paoma_1008/article/details/79827803
    • com.esotericsoftware.kryo.KryoException: Class cannot be created (missing no-arg constructor): java.util.Collections$SynchronizedRandomAccessList
    • com.esotericsoftware.kryo.KryoException: Encountered unregistered class ID: XXXX